-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert "Improve [Async]ContextDecorator type hinting (#13416)" #13436
Revert "Improve [Async]ContextDecorator type hinting (#13416)" #13436
Conversation
This reverts commit 57d7c43. The attempted fix loses all type overload information during type inferencing, so postpone fixing the issue until we have a solution which doesn't impose such a dramatic loss in functionality. Reopens python#13403
Diff from mypy_primer, showing the effect of this PR on open source code: jax (https://github.com/google/jax)
- jax/_src/api.py:2671: error: Incompatible return value type (got "_WrappedCallable[[VarArg(Any), KwArg(Any)], Any]", expected "F") [return-value]
- jax/experimental/jax2tf/jax2tf.py:3059: error: Argument 1 has incompatible type "_GeneratorContextManager[NameStack, None, None]"; expected "Callable[[partial[Sequence[Any]]], partial[Sequence[Any]]]" [arg-type]
- jax/experimental/jax2tf/jax2tf.py:3059: note: "_GeneratorContextManager[NameStack, None, None].__call__" has type "Callable[[Arg(Callable[_P, _R], 'func')], _WrappedCallable[_P, _R]]"
cki-lib (https://gitlab.com/cki-project/cki-lib)
+ tests/test_metrics.py:75: error: Call to untyped function "dummy_function" in typed context [no-untyped-call]
|
Discourse thread with background on this: https://discuss.python.org/t/defining-overload-preserving-signatures-for-wrapped-callables/78350 |
What is the current status here? We're currently holding off on a typeshed sync in Mypy to wait for a resolution here. See python/mypy#18580 |
I'm not sure. When I submitted the initial change, I thought it was a simple bug fix, but it turned out it opened up a giant can of worms around whether or not type checkers should be keeping track of overload details when a parameter spec and result type pair are combined as a callable interface in a generic class definition. |
this also breaks methods decorated with a from contextlib import contextmanager
from collections.abc import Generator
@contextmanager
def foo() -> Generator[None]: ...
asdf = foo()
class Foo:
@foo()
def bar(self):
...
Foo().bar() # Argument missing for parameter "self" (reportCallIssue) |
…ython#13436) This reverts commit 57d7c43. The attempted fix loses all type overload information during type inferencing, so postpone fixing the issue until we have a solution which doesn't impose such a dramatic loss in functionality. Reopens python#13403
This reverts commit 57d7c43.
The attempted fix loses all type overload information during type inferencing, so postpone fixing the issue until we have a solution which doesn't impose such a dramatic loss in functionality.
Reopens #13403