Revert "Improve [Async]ContextDecorator type hinting (#13416)"#13436
Merged
JelleZijlstra merged 1 commit intopython:mainfrom Feb 14, 2025
Merged
Revert "Improve [Async]ContextDecorator type hinting (#13416)"#13436JelleZijlstra merged 1 commit intopython:mainfrom
JelleZijlstra merged 1 commit intopython:mainfrom
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
Contributor
|
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]
|
Contributor
Author
|
Discourse thread with background on this: https://discuss.python.org/t/defining-overload-preserving-signatures-for-wrapped-callables/78350 |
Contributor
|
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 |
Contributor
Author
|
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. |
Contributor
|
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) |
Xiddoc
pushed a commit
to Xiddoc/typeshed
that referenced
this pull request
Feb 16, 2025
…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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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