Skip to content
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

Merged
merged 3 commits into from
Aug 21, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn requested a review from JelleZijlstra August 21, 2022 16:39
@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Member

@JelleZijlstra JelleZijlstra left a 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
Copy link
Member

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?

Copy link
Member Author

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.

@sobolevn sobolevn merged commit d315403 into python:master Aug 21, 2022
@sobolevn
Copy link
Member Author

Thanks for noticing it!

@vnmabus
Copy link

vnmabus commented Aug 31, 2022

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?

@hauntsaninja
Copy link
Collaborator

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

@vnmabus
Copy link

vnmabus commented Aug 31, 2022

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 😅️.

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.

4 participants