-
-
Notifications
You must be signed in to change notification settings - Fork 179
Fix __class_getitem__
to be positional-only
#3410
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
Conversation
I've looked around and failed to find information about key parameter being required a positional-only: Edit: |
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.
If you would like, you can rename generic
to item
to be consistent with typeshed.
LGTM;
Update sprite.pyi
ac8c795
to
e76176b
Compare
I updated the code to use I also want to keep code changes out of this stubs PR so I am not changing the parent classes in the implementation, though someone could take it up in the future if interested. |
I played around a bit with list's implementation, it being positional only seems to be standard. >>> list.__class_getitem__(key=int)
Traceback (most recent call last):
File "<python-input-9>", line 1, in <module>
list.__class_getitem__(key=int)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: list.__class_getitem__() takes no keyword arguments Also ofc class getitem is meant to be used by type hints, and trying to use a keyword there is a syntax error. >>> list[key=int]
File "<python-input-5>", line 1
list[key=int]
^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='? |
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.
LGTM, thanks!
As noted by @aatle in #3398,
__class_getitem__
is positional only, and stubtest on python 3.13 complains about this issue. This PR fixes that.