-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
ParamSpec
must not raise errors on valid attr access
#13472
Conversation
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
def func1(callback: Callable[P1, str]) -> Callable[P1, str]: | ||
def inner( | ||
*args: P1.typo, # E: Use "P1.args" for variadic "*" parameter \ | ||
# E: Name "P1.typo" is not defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How hard would it be to make this say something like "ParamSpec has no attribute 'typo'" instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite hard :)
Right now checkmember
is not involved at all, this is semanal
-level check.
We can change the error message (special case it for ParamSpec
), but I don't think this is a good idea.
Thanks for noticing it! |
This still fails for me in the following example in Mypy playground (https://mypy-play.net/?mypy=master&python=3.10&gist=2f63e549be8913d2878f366612bb7b00): from typing import ParamSpec, Callable, TypeVar
T = TypeVar("T")
P = ParamSpec("P")
def twice(
f: Callable[P, T],
**kwargs: P.kwargs,
) -> T:
return f(**kwargs) Is this not supposed to work? |
It works just fine on master, the problem is that mypy-play.net's master is just some really old hardcoded revision. See ymyzk/mypy-playground#162 / ymyzk/mypy-playground#158 |
Ok, I assumed it was automatically pulling the latest changes 😅️. |
Refs #13468
CC @JelleZijlstra