Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

asottile
Copy link
Contributor

@asottile
Copy link
Contributor Author

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:

(int, Any) -> Any

(a correct decorator allows it to infer (int, int) -> int but I am quite confused how it figured out one of the parameters but not both and then not the return value 🤔)

@JelleZijlstra
Copy link
Member

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.

@asottile
Copy link
Contributor Author

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 🤔

@asottile
Copy link
Contributor Author

oh to be clear the code doesn't produce an error -- I'm specifically talking about dmypy suggest

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants