-
-
Notifications
You must be signed in to change notification settings - Fork 3k
use is_same_type when resolving decorators in suggestions #19319
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
base: master
Are you sure you want to change the base?
Conversation
this does seem to have a strange side-effect that I can't quite wrap my head around using this sample code: from __future__ import annotations
from typing import Callable, Protocol, TypeVar, Any
from typing_extensions import ParamSpec, TypeAlias
def dec(f: Callable[..., Any]) -> Callable[..., Any]:
return f
@dec
def f(x, y):
return x + y
f(1, 2) before this produced "Object t.f is a decorator we can't handle" but now it produces:
(a correct decorator allows it to infer |
Is the code sample in your last message correct? I don't get that error in the playground when I try the code in your message, but maybe you meant something else. You imported ParamSpec but didn't use it. |
yeah the imports are left over from making the testcase I added in this PR. weird that you don't get the same results though 🤔 |
oh to be clear the code doesn't produce an error -- I'm specifically talking about |
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Hm, this seems to be the reason why Dumping the call sites, we have this single entry there:
Where i-th element of a 2D list contains types mapped to i-th formal argument of the function. from __future__ import annotations
from typing import Callable, Any
def dec(f: Callable[..., Any]) -> Callable[..., Any]:
return f
@dec
def f(x, y, z):
return x + y
f('', 0, 1) It might be better to disallow such decorators again and revert/update #19072... But this change (using |
followup to https://github.com/python/mypy/pull/19072/files/55ef5994102771f07cfe30b2123c4de22c7a2869#r2083298219