-
Notifications
You must be signed in to change notification settings - Fork 360
Description
Bug Report
The type hint for the screen parameter in arcade.Window.__init__() is missing an Optional[] hint, and the default value is None. This causes type checkers like Pyright to underline super().__init__() in a subclass of arcade.Window with default arguments as an error. If possible I would like to work on this issue myself.
Lines 85 to 89 in 7180783
| update_rate: Optional[float] = 1 / 60, | |
| antialiasing: bool = True, | |
| gl_version: Tuple[int, int] = (3, 3), | |
| screen: pyglet.canvas.Screen = None, | |
| style: Optional[str] = pyglet.window.Window.WINDOW_STYLE_DEFAULT, |
System Info
Arcade 2.6.15
vendor: Intel
renderer: Intel(R) UHD Graphics
version: (4, 6)
python: 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]
platform: win32
Actual behavior:
Pyright underlines the __init__() call with a type error.
Expected behavior:
There should be no type errors for the default arguments, especially when other parameters use the Optional[] hint.
Steps to reproduce/example code:
In VS Code, enable type checking by setting the Python > Analysis > Type Checking Mode option to basic or strict.
Paste the following code into a Python file.
import arcade
class MyGame(arcade.Window):
def __init__(self):
super().__init__()Enhancement request:
Fix the typing issue.
What should be added/changed?
Add Optional[] around the pyglet.canvas.Screen type hint.
screen: pyglet.canvas.Screen = None,Changed to:
screen: Optional[pyglet.canvas.Screen] = None,What would it help with?
It would remove the Pyright error.
