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
Describe the bug
If I have a generic dataclass with a ParamSpec in its generic parameters, and it has a method decorated with @contextmanager or @asynccontextmanager that accepts the ParamSpec's args/kwargs, and I use a functools.partial as the input (which is used to infer the ParamSpec), there seems to be a bug where pyright thinks I need to pass a value for self on the method. Minimal reproduction below.
Please let me know if I'm misunderstanding something, but as far as I can tell the issue seems to be coming from the combination of all three of these things (ParamSpec, contextmanager, and partial). If I remove any one of these, the spurious type error goes away.
Code or Screenshots
The following examples execute without errors and as far as I can tell should not produce type errors. I've included the pyright errors and printed outputs in in-line comments.
Reductions of the above that do NOT produce type errors:
Each of these is basically the same as the problematic code above, showing that it really is the combination of all three of these things together that causes the problem.
Describe the bug
If I have a generic dataclass with a
ParamSpec
in its generic parameters, and it has a method decorated with@contextmanager
or@asynccontextmanager
that accepts the ParamSpec's args/kwargs, and I use afunctools.partial
as the input (which is used to infer theParamSpec
), there seems to be a bug where pyright thinks I need to pass a value forself
on the method. Minimal reproduction below.Please let me know if I'm misunderstanding something, but as far as I can tell the issue seems to be coming from the combination of all three of these things (ParamSpec, contextmanager, and partial). If I remove any one of these, the spurious type error goes away.
Code or Screenshots
The following examples execute without errors and as far as I can tell should not produce type errors. I've included the pyright errors and printed outputs in in-line comments.
Sync example:
Async example:
VS Code extension or command-line
Command line. I get this behavior on both v1.1.389 and v1.1.395.
Pyright is awesome, thank you so much!
The text was updated successfully, but these errors were encountered: