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

@contextmanager type hints don't pass through from decorated function #5014

Closed
CalebEverett opened this issue Feb 10, 2021 · 7 comments
Closed

Comments

@CalebEverett
Copy link

Per this issue, it appears that the stub for contextmanager has not been updated for PEP612 so type hints aren't showing for the underlying function arguments.

@srittau srittau added the reason: inexpressable Closed, because this can't be expressed within the current type system label Feb 10, 2021
@srittau
Copy link
Collaborator

srittau commented Feb 10, 2021

PEP 612 is not supported yet in typeshed. See #4827.

@CalebEverett
Copy link
Author

Is there anything I can do to help out?

@srittau
Copy link
Collaborator

srittau commented Feb 10, 2021

It seems that mypy already has a PR (python/mypy#8645), maybe @hauntsaninja can give some insight here. google/pytype#786 makes it sound as if there could be a simple solution to at least partially support (or at least not block) PEP 612 in pytype. Maybe @rchen152 could give some pointers.

@rchen152
Copy link
Collaborator

Sorry for the slow response - somehow missed the notification for this comment. I'll try to add some minimal parse support for PEP 612 to pytype. (I'll probably just map everything to Any under the hood.)

@srittau
Copy link
Collaborator

srittau commented May 4, 2021

I am going to close this for now, as is standard for issues labeled "inexpressible". We can revisit this when PEP 612 is implemented in supported type checkers.

@srittau srittau closed this as completed May 4, 2021
@srittau srittau removed the reason: inexpressable Closed, because this can't be expressed within the current type system label Sep 27, 2021
@srittau
Copy link
Collaborator

srittau commented Sep 27, 2021

PEP 612 is not mostly implemented, so this can be revisited. Reopening.

@srittau srittau reopened this Sep 27, 2021
@JelleZijlstra
Copy link
Member

def contextmanager(func: Callable[_P, Iterator[_T]]) -> Callable[_P, _GeneratorContextManager[_T]]: ...  # type: ignore[misc]

This is fixed.

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

No branches or pull requests

4 participants