-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Add runtime support for pygame.sprite.AbstractGroup
subscripts
#3053
base: main
Are you sure you want to change the base?
Add runtime support for pygame.sprite.AbstractGroup
subscripts
#3053
Conversation
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, with this change one doesn't have to wrap the subscript inside a string for annotations.
I don't think importing typing inside the function is a problem because:
- The class is subscripted a little amount of times
- Sequential subscripts will use the cached module, so it's just like if you import it at the top of the file
Regarding the generic implementation, I think the sprite stubs do a good enough job with subclassing Generic and using the typevars, so I think the actual implementation can ignore all that and only implement class getitem for the runtime.
Thanks :)
Now that we've dropped 3.8 is this possible to do without using undocumented features? |
e0c0698
to
7f3b58f
Compare
I was wondering whether some of this should be put into |
Currently this code would fail at runtime
with
Currently a viable alternative is to use
or
However, I feel as though that makes it more cumbersome for the end user.
Also this solves a cross compatibility issue with pg/pg
Besides this, the type stubs for
pygame.sprite
have to be massively revised, they are quite flawed it seems, especially when thisGeneric
mechanism is taken into account, but I will handle that in a another PR.