-
Notifications
You must be signed in to change notification settings - Fork 335
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
Update section __init__ type hints #2527
Conversation
Update left, bottom, width, and height to hint that they accept int or float
working on the failed checks |
We do have arcade/arcade/types/numbers.py Line 14 in 7717e3f
|
Looking at the docs for type hinting: # On Python 3.10+, use the | operator when something could be one of a few types
x: list[int | str] = [3, 5, "test", "fun"] # Python 3.10+
# On earlier versions, use Union
x: list[Union[int, str]] = [3, 5, "test", "fun"] We should either use I assume dropping support for Python 3.9 is going to be significantly more involved than using |
I think |
TL;DR: Soon (in a few months) For the moment switching back to
As a bonus, the doc cited is mypy doc. They have ideas which clash with our codebase(s). Specifically, we face the same issues as pyglet does with mypy due to [[tool.mypy.overrides]]
# mypy incorrectly reports issues everywhere in pyglet.math because:
# 1. pyglet.math is almost entirely typing.NamedTuple subclasses
# 2. The mypy project has the following long-standing stance on
# supporting collections.namedtuple and typing.NamedTuple:
# "Duplicate of #5613, still low priority, better use dataclasses,
# as suggested above."
# https://github.com/python/mypy/issues/5944#issuecomment-441285456
module = "pyglet.math"
ignore_errors = true |
I think it was lazy shorthand / a way to make pyright pass in specific cases. |
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.
In my eyes, this has better legiblity than AsFloat
. The tab-completion ergonomics aren't as good, but 🤷
* Update section __init__ type hints * Update left, bottom, width, and height to hint that they accept int or float * fixes for the automated checks
Update left, bottom, width, and height to hint that they accept int or float
fixes #2525