HomePhorge

(PUP-2794) Change Callable to mean "can be called with"
1e42475f4fb5Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(PUP-2794) Change Callable to mean "can be called with"

It is more meaningful to check that a Callable can be called with
certain types (exact or more generic) than to check the reverse.

This alters the meaning of Callable assignability so that a more generic
Callable is accepted. While this seems counterintuitive from the
perspective of the type system, it is the constraint that is expected as
the constraint being expressed means "Must be callable with arguments of
these types", and a more generic callable is just that.

The current implementation got that wrong, and will actually accept
callables that can in fact not be called.

This also alters the assert_type function that declared that it would
call a given block with Any, Any, when in fact it will call with
Type, Type.

Note, that a function that after this delares that it calls
Callable[Any] will enforce that the given callable is Any. If the intent
is to accept any callable, the type should be given as just Callable.

Details

Provenance
Henrik Lindberg <henrik.lindberg@cloudsmith.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU721fe626adf7: Merge branch 'pr/2810'
Branches
Unknown
Tags
Unknown

Event Timeline

Henrik Lindberg <henrik.lindberg@cloudsmith.com> committed rPU1e42475f4fb5: (PUP-2794) Change Callable to mean "can be called with" (authored by Henrik Lindberg <henrik.lindberg@cloudsmith.com>).Jun 30 2014, 5:40 PM