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
Some type hint and examples fixes #1817
Conversation
Oops, guess I missed out some What's the deal with the https://www.pygame.org/docs/ref/font.html#pygame.font.Font.set_bold Is this a case of the underlying c code using ints and not casting back to python's bool type? |
Docs are wrong (at least when I tested those functions) |
Looked over the changes and then tried it out in pygame_gui and it all seems to work well with the PyCharm inspection. Looks like type checkers don't care actually about passing a bool into an int - though it is slightly confusing for the auto complete hints. I think this should be merged and we can figure out any ints that should be bools later. |
This is because of numeric object "hierarchy". Basically it goes like float -> int -> bool -> None. So for example type hint for float will accept float, int, bool and None, int will also accept bool and 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.
🎉 👍
pygame.Color
andpygame.math.Vector
pygame.font
(bool -> int)NOTE: If you use PyCharm you won't be able to see the changes with hashable/unhashable types, haven't checked if mypy recognize it, but I used example from python/typing#74 (ok just checked mypy and it also doesn't accept hash = None as non hashable object)