-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
Expand __init__ parameters for Window
#3295
Expand __init__ parameters for Window
#3295
Conversation
Co-authored-by: Ankith <[email protected]>
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 🎉
allow_high_dpi: bool = ..., | ||
mouse_capture: bool = ..., | ||
always_on_top: bool = ..., | ||
utility: bool = ..., | ||
) -> None: ... |
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.
) -> None: ... | |
**flags: bool, | |
) -> None: ... |
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.
Hi, why would that be necessary? any flag that is not in the current parameter list will result in an error. it seems to me the code you are suggesting doesn't reflect what's going on in C. if a new flag will be added, a new keyword parameter will be added too.
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.
Okay. I was thinking about the original signature and assumed that it was supported.
If flags are to be deprecated though, will they be removed?
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.
I thought about it too, like, "will this make it harder to remove things?" not really. what is in the docs is official and public. just because it wasn't in the stubs before doesn't mean it could just be removed. if a flag is deprecated, the keyword parameter will be removed. your linter will complain, but your code won't fail, it'll just output a warning. the linting failing is actually good, because it discourages usage, just like @deprecated
does.
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.
Disallowing deprecated parameters in typing is not appropriate.
Either, the deprecated parameters are still compatible with typing via the **kwargs
parameter, or there is a deprecated overload for them (possibly using **kwargs
). There might also be runtime warnings to accompany them.
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.
the warning are sure. how would the overload be compatible with mypy? should it be added now? perhaps when deprecating the keyword argument will not be removed, but it could be typehinted in some special way, I hope so. Either way, I believe it to be slightly outside of scope of this PR. good for noticing tho :)
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.
Sure.
When a flag is deprecated, we can either keep it in the signature or create a separate deprecated overload.
Thanks for clarifying this.
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!
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.
After reading all messages and the content of the code changes, I can say that it looks good to me.
Thanks for the PR !
Window
Window
It's a bit annoying having to open the docs every time to remember if a flag exists or not and since this are bool flags and not int flags I think this adds clarity. Additionally, when you start typing a flag your IDE will suggest it to you and you'll spell it right.
Finally I used
...
instead of False because the flag doesn't really enable or disable the feature, it justs sets the flag for SDL to handle. the default for that feature might be True in that specific os, so False would be incorrect, imo. Many libraries I saw used this signature, but I can change it if it's not liked.I used the docs to get the flags, if some flags are to be deprecated for SDL3 I can omit them, of course.