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 sdl2_video types #2664
Add sdl2_video types #2664
Conversation
Questions from @MightyJosip posted on discord: Great job 🎉 , this is one of the last things _sdl2 is missing before I can start trying it out. Didn't check if the all types are correct (tho I believe they indeed are, after all you are the one that wrote that code), but here are some of my general suggestions/questions after I briefly "reviewed" it:
|
The constants live in the
Ugh, I used that a lot. I'll have to look into it, but you're probably right.
Good spot. I think the no
This is one of the most weird areas of the current video API. Both implementations implement these as properties, if I remember correctly. I think the Cython one is only color objects, but mine can take any valid color data. The way I see it working is that you can set it using any valid color format, but when you get it out, it's always going to be a Color object.
Good question. There's an _sdl2 init.py: https://github.com/pygame/pygame/blob/main/src_py/_sdl2/__init__.py. That's how the _sdl2 stuff is actually exposed. |
One extra thing
About the color thing right now type hints accepts Constants are ok the way they are written right now, also the import thing as well |
Ok, I fixed the "easy stuff," which is everything except the
Cython implementation needs Color objects, C implementation is fine with anything iirc. I guess the types should be accurate, not aspirational, so I fixed it. |
Questions from @zoldalma999 posted on discord: Hey Starbuck, I have a few questions/comments about your pr, 2664 (_sdl2.video types):
I might be wrong on some of these tho, but these are the things I noticed |
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.
Very good. I think we can merge this one in?
(The typing mistakes can be done either in another PR or this one IMHO)
Ok, I think it's ready now. I also realized I forgot the I'm really the wrong person to be doing this PR since I don't use typing at all, and I don't even understand how to check if it's right half the time, but I wanted to keep making progress on _sdl2 somehow. |
I wanted to keep making some progress on _sdl2, so I decided this was a good small thing I could get done.
With this, we have skeleton documentation and full typing for the _sdl2.video system.
By putting this in I don't mean to solidify the current system against future change, in fact I have several things I would like to change with it. But that can't happen until #2564 is resolved.
These were tested with mypy against mcpalmer's dancefont, tilemap, and Flyboy programs, along with the
pygame/examples
video.py program.Also, I didn't know you could run
black
on pyi files, but you can. I used that to make it nice and pretty.