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. |
* 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