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
{{ message }}
Repository navigation
ParamSpec parameters don't match __init__ parameters of class #12986
You get the same error without the decorator (delete the @ character and the last two lines entirely). The error is at the instantiation of the partial object.
The problem is the use of an unbound type in a way that mypy cannot handle. Where the error message says "Any" is misleading; the internal state of mypy still has "P" unbound. Notice that mypy is happy if you explicitly annotate or cast with the same dubious type mypy already claims to think it has:
con: Type[custom_vjp[Any]] = custom_vjp
partial(con, x=1) # no issues found
partial(cast(Type[custom_vjp[Any]], custom_vjp), x=1) # no issues found
That's proof that the mypy error message is not really telling you what's gone wrong inside mypy.
I am working on a plugin to properly handle functools.partial and partialmethod. I'll be sure this handle this test case.
Activity
kstauffer commentedon Jun 20, 2022
You get the same error without the decorator (delete the
@character and the last two lines entirely). The error is at the instantiation of thepartialobject.The problem is the use of an unbound type in a way that mypy cannot handle. Where the error message says "Any" is misleading; the internal state of mypy still has "P" unbound. Notice that mypy is happy if you explicitly annotate or cast with the same dubious type mypy already claims to think it has:
That's proof that the mypy error message is not really telling you what's gone wrong inside mypy.
I am working on a plugin to properly handle functools.partial and partialmethod. I'll be sure this handle this test case.
NeilGirdhar commentedon Jun 21, 2022
Awesome!! Really looking forward to your plugin. And thank you for diagnosing the error and providing a workaround.
ilevkivskyi commentedon Aug 16, 2023
The original example works on master, likely fixed by #15837