Skip to content
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

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

ncoghlan
Copy link
Contributor

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

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
Copy link
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]

@ncoghlan
Copy link
Contributor Author

@cdce8p cdce8p mentioned this pull request Feb 1, 2025
@cdce8p
Copy link
Contributor

cdce8p commented Feb 9, 2025

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

@ncoghlan
Copy link
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.

@DetachHead
Copy link
Contributor

this also breaks methods decorated with a @contextmanager:

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)

playground

@JelleZijlstra JelleZijlstra merged commit 3f41b30 into python:main Feb 14, 2025
58 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants