You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using contextmanager decorator on an object method, which uses a ParamSpec, then the inferred type of the resulting method seems to be one for an unbounded method. And therefore it expects an extra "self" parameter at the beginning.
Expecting no error.
Revel type should have shown something like def (builtins.int, builtins.str) -> contextlib._GeneratorContextManager[None]
Actual Behavior
main.py:16: error: Too few arguments for "a_cm_with_param_spec" of "AClass" [call-arg]
main.py:16: note: Revealed type is "def (self: __main__.AClass[[builtins.int, builtins.str]], builtins.int, builtins.str) -> contextlib._GeneratorContextManager[None]"
main.py:16: error: Argument 1 to "a_cm_with_param_spec" of "AClass" has incompatible type "int"; expected "AClass[[int, str]]" [arg-type]
main.py:16: error: Argument 2 to "a_cm_with_param_spec" of "AClass" has incompatible type "str"; expected "int" [arg-type]
Found 3 errors in 1 file (checked 1 source file)
Your Environment
Mypy version used: 1.2.0
Mypy command-line flags:
Mypy configuration options from mypy.ini (and other config files):
Bug Report
When using contextmanager decorator on an object method, which uses a ParamSpec, then the inferred type of the resulting method seems to be one for an unbounded method. And therefore it expects an extra "self" parameter at the beginning.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=bc44336f0994253277609e8163f1e5b5
Expected Behavior
Expecting no error.
Revel type should have shown something like
def (builtins.int, builtins.str) -> contextlib._GeneratorContextManager[None]
Actual Behavior
Your Environment
mypy.ini
(and other config files):Comments
__init__
: https://mypy-play.net/?mypy=latest&python=3.11&gist=f5c32e85161882381933f637628d84baThe text was updated successfully, but these errors were encountered: