-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add missing attributes to contextlib._(Async)GeneratorContextManager
#6676
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Hmm, well mypy's support of |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have no idea what those pytype errors mean. |
…meters for `_GeneratorContextManager` has not changed, should be done in a separate PR)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
contextlib._GeneratorContextManagerBase
_(Async)GeneratorContextManager
_(Async)GeneratorContextManager
contextlib._(Async)GeneratorContextManager
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
I don't see any obvious issues in how _P is being used here, so the test failure is likely due to a bug in pytype - sorry about that! I'll take a look, but it'll be at least a week before a fix is released, since we're currently in a holiday freeze. |
Of course, no worries!! |
I've taken out the use of |
Diff from mypy_primer, showing the effect of this PR on open source code: pyinstrument (https://github.com/joerick/pyinstrument)
- pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[object], None]")
+ pyinstrument/vendor/decorator.py:295: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
- pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[object], None]")
+ pyinstrument/vendor/decorator.py:301: error: Incompatible types in assignment (expression has type "Callable[[Any, Any, VarArg(Any), KwArg(Any)], Any]", variable has type "Callable[[_GeneratorContextManager[_T_co], Callable[..., Iterator[_T_co]], Tuple[Any, ...], Dict[str, Any]], None]")
|
I figured out why pytype was erroring here! The ParamSpec attribute for keyword args is called |
@rchen152 oh wow, I feel like such an idiot 🤦 thanks so much for looking into it!! |
* Don't create multiple TypeVars for the same ParamSpec. We were creating a new TypeVar every time we saw a ParamSpec used in a class definition, leading to "Duplicate top-level identifier" errors. * Show a more helpful error message when P.args or P.kwargs is misspelled. Misspelling a ParamSpec attribute previously produced a mysterious "Can't find pyi for <ParamSpec name>" error at the dependency loading phase. See python/typeshed#6670 and python/typeshed#6676. PiperOrigin-RevId: 419457152
I think that python#6676 showed that Paramspec didn't work, but that wasn't actually the fault of _GeneratorContextManagerBase.
I think that python#6676 showed that Paramspec didn't work, but that wasn't actually the fault of _GeneratorContextManagerBase.
No description provided.