FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`ParamSpec` must not raise errors on valid attr access by sobolevn · Pull Request #13472 · python/mypy · GitHub

Repository navigation

ParamSpec must not raise errors on valid attr access - #13472

Merged
sobolevn merged 3 commits into
python:masterfrom
sobolevn:paramspec-attr-access
Aug 21, 2022
Merged

sobolevn merged 3 commits into
python:masterfrom
sobolevn:paramspec-attr-access

Conversation

Copy link
Copy Markdown
Member

sobolevn requested a review from JelleZijlstra August 21, 2022 16:39

This comment has been minimized.

2 similar comments

This comment has been minimized.

Copy link
Copy Markdown
Contributor

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

JelleZijlstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

How hard would it be to make this say something like "ParamSpec has no attribute 'typo'" instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 merged commit d315403 into python:master Aug 21, 2022

Copy link
Copy Markdown
Member Author

Thanks for noticing it!

vnmabus commented Aug 31, 2022

Copy link
Copy Markdown

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?

Copy link
Copy Markdown
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 commented Aug 31, 2022

Copy link
Copy Markdown

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

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL