def apply(f: Callable[[int], int], x: int) -> int: return f(x) class Add5(object): def __call__(self, x: int) -> int: return x + 5 apply(Add5(), 5)
This code snippet doesn't type check because Mypy doesn't treat Add5() as a Callable[[int], int]
Moved to 0.5 since this comes up pretty frequently.
I'm going to start looking into this one.
WIP at https://github.com/margaret/mypy/tree/user_defined_callable (thanks @rwbarton for helping) Currently debugging broken tests, specifically
class A(type): def __init__(self) -> None: pass def f(x: type): pass f(A())
Does not work and returns error: Argument 1 to "f" has incompatible type Callable[[Any, Any], Any]; expected "type"
Have you tried putting a pdb.set_trace() call in errors.Errors.report() and tracing back to the cause of this message?
I believe type is special in some ways, maybe that's biting you?
On Fri, Jun 3, 2016 at 7:33 PM, Margaret Sy notifications@github.com wrote:
WIP at https://github.com/margaret/mypy/tree/user_defined_callable Currently debugging broken tests, specifically class A(type): def init(self) -> None: pass def f(x: type): pass f(A()) Does not work and returns error: Argument 1 to "f" has incompatible type Callable[[Any, Any], Any]; expected "type" — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub #797 (comment), or mute the thread https://github.com/notifications/unsubscribe/ACwrMlU02GpgXeGUJobz55IoQXJZ9oczks5qIOP8gaJpZM4FtydI .
WIP at https://github.com/margaret/mypy/tree/user_defined_callable Currently debugging broken tests, specifically
class A(type): def init(self) -> None: pass def f(x: type): pass f(A())
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub #797 (comment), or mute the thread https://github.com/notifications/unsubscribe/ACwrMlU02GpgXeGUJobz55IoQXJZ9oczks5qIOP8gaJpZM4FtydI .
--Guido van Rossum (python.org/~guido)
Moving to an earlier milestone since the partial issue is kind of important.
A related issue is the join of Callable and an instance type that defines __call__ (see #2779).
@ilevkivskyi Are you still working on this? If not it's better to un-assign.
Protocols #3132 will fix this, no additional work here will be needed when they are merged.
requests: explicitly support AuthBase for Session.auth
This is now fixed by #3132
requests: add more accurate stubs for certain fields of the Session o…
Activity
JukkaL commented on May 5, 2016
Moved to 0.5 since this comes up pretty frequently.
margaret commented on Jun 3, 2016
I'm going to start looking into this one.
margaret commented on Jun 4, 2016
WIP at https://github.com/margaret/mypy/tree/user_defined_callable (thanks @rwbarton for helping)
Currently debugging broken tests, specifically
class A(type): def __init__(self) -> None: pass def f(x: type): pass f(A())Does not work and returns
error: Argument 1 to "f" has incompatible type Callable[[Any, Any], Any]; expected "type"
gvanrossum commented on Jun 4, 2016
Have you tried putting a pdb.set_trace() call in errors.Errors.report()
and tracing back to the cause of this message?
I believe type is special in some ways, maybe that's biting you?
On Fri, Jun 3, 2016 at 7:33 PM, Margaret Sy notifications@github.com
wrote:
--Guido van Rossum (python.org/~guido)
gvanrossum commented on Nov 28, 2016
Moving to an earlier milestone since the partial issue is kind of important.
JukkaL commented on Jan 31, 2017
A related issue is the join of Callable and an instance type that defines __call__ (see #2779).
gvanrossum commented on May 5, 2017
@ilevkivskyi Are you still working on this? If not it's better to un-assign.
ilevkivskyi commented on May 5, 2017
Protocols #3132 will fix this, no additional work here will be needed when they are merged.
requests: explicitly support AuthBase for Session.auth
requests: explicitly support AuthBase for Session.auth
ilevkivskyi commented on Aug 19, 2017
This is now fixed by #3132
requests: add more accurate stubs for certain fields of the Session o…