The structural type of typing.Callable #1385
Replies: 3 comments 3 replies
-
Before we discuss potential solutions, it would be good to understand what problem you're trying to solve. Why do you want to access the I'm not aware of this ever coming up before in typing forums, so I think you're doing something quite unusual here. As you mentioned, |
Beta Was this translation helpful? Give feedback.
-
I wanted to revisit this, because it is also unclear whether mypy, pyright and pytype all pass the following snippet, but it fails at runtime:
|
Beta Was this translation helpful? Give feedback.
-
This is why I wanted to make types.FunctionType subscriptable because I do agree the current behaviour is very undesirable and Callable not being a structural type with just dunder call is very strange |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
It seems a bit unclear what
typing.Callable
is from the structural perspective. PEP-484 introduced it as a special-form and an alias ofcollections.abc.Callable
, which has a__call__
method. However, neither mypy nor pyright seem to allow looking up__call__
on a value of callable typemypy
pyright
Should we clarify the expected behavior?
Beta Was this translation helpful? Give feedback.
All reactions