- Notifications
You must be signed in to change notification settings - Fork3.8k
Add__new__ and__init__ functions for some types#3001
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Why not make Joystick a class like the rest? Seems simpler and prettier than dealing with JoystickTypes all over the place. Would it be better for Clock to have an To get rid of the failing setup.py lint CI, you can run |
I got my hands on a linux laptop with a builtin webcam, so I did that one as
Because the joystick function does not always always construct a new object, but
You are right, I changed it.
Ah. Yeah, I forgot to do it again. |
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 for the PR! 👍 🎉
(PS: lint is still failing 😅)
Starbuck5 commentedFeb 3, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We could override I don't want to merge this in with the current JoystickType documentation changes, because it makes it seem more complex and exposes that type as part of our API, when we might not want that. I'd prefer the joystick status quo. Everything else looks good, but I'll be sure to test webcam on Windows.[It still works] For the failing format status, you can rebase the branch against main. It's because black updated, and so now all the in progress branches will potentially get a few unrelated changes. But novial put through a PR that fixes it in main, if you can rebase. |
I don't really prefer status quo, I prefer things documented as accurate to the implementation as possible. We could also investigate implementing |
Starbuck5 commentedFeb 3, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ankith26 I have to confess my objection originally stems from it making the docs ugly. But we haven't gotten any issues with the status quo, unlike the Event status quo which kicked off this PR. If we haven't decided to go with JoystickType or turn Joystick into a class of its own, it shouldn't be merged with the rest of this PR. I believe everything else is good. |
Sorry, there's a conflict now with _camera.c because I merged another PR. |
Starbuck5 left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Thanks!
This is one of those things that future contributors will never think of but will help them out. Because of course the objects are objects, not functions. Why would they be functions? 😄
One sorta suspicious thing I found is that PyChannel_New is still around and used, and the new channel_init has copied the same routines. Just in case one of them is changed in the future, that could trip someone up. Maybe add a comment? What do you think?
Is Event() now the preferred way? Should the docs assert that?
I've tested this locally and it works.
Anyways, this PR is good to go code wise, AFAICT, there's a couple things to think about, but it could be merged without that. There's also conflicts now (probably from my PRs sorry)
Uh oh!
There was an error while loading.Please reload this page.
As per#2867, I added
__init__and/or__new__to the following classes:I also documented that Joysticks do not have these functions and can only be opened trough the
pygame.joystick.Joystickfunction.PixelArray seemed to have already exported it's class properly. I did not want to touch the Camera class, since I do not have a camera to test with.