Repository navigation
Make mypy and pyright fail CI, and fix their errors - #2942
Merged
Merged
Conversation
Fixing the type errors turned up three crashes: - Window subclasses that stored a camera as self.camera (platformer tutorial steps 7-19, custom_sprite, the lights tutorial) raised AttributeError on startup. Window.camera is pyglet's default camera. They now use self.world_camera, and assigning Window.camera explains. - pixelated_ui() used pyglet 2 font filter attributes. - InputManager.parse() called a function renamed in #2289. A file-wide type: ignore had hidden it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mypy and pyright now fail the Code Quality check, like the ruff steps since #2940. Both had existing errors (40 mypy, 11 pyright), and all of them are fixed. Three were real crashes:
Bugs found
self.cameraon a window crashed: platformer tutorial steps 07–19,gl/custom_sprite, the lights tutorial andexperimental/perspective_parallaxstored their camera asself.cameraon anarcade.Windowsubclass. Since the move to pyglet 3,Window.camerais the default camera pyglet draws Labels and batches with (update pyglet to version 3.0.dev7 and improve camera compatibility #2880), so they all crashed on startup withAttributeError: property 'camera' ... has no setter. Before update pyglet to version 3.0.dev7 and improve camera compatibility #2880, pyglet's own setter would have rejected an arcade camera anyway.self.world_camera, which pairs with the tutorial'sgui_camera. Renames stay on the same lines, so the tutorial'semphasize-linesstill match.Window.cameranow has a setter that raises a clearerAttributeError: "Window.camera is the default camera pyglet draws with, and can't be assigned. Store your camera under another name, such as self.world_camera." User code with the old tutorial pattern still fails, but now it says how to fix it. A setter that accepted the camera would break pyglet's text drawing.pixelated_ui()crashed: it set pyglet 2'sFont.texture_min_filter/texture_mag_filterthroughpyglet.gl, which pyglet 3 doesn't have. It now setsFont.filters = TextureFilter.NEAREST. Theexp_animations_2example had the same code.InputManager.parse()crashed: it calledinputs.parse_instance(), which More future.input cleanup work #2289 renamed toparse_mapping_input_enum(). The input modules had a file-wide# type: ignore, which hid this. It also made mypy seearcade.inputas empty, which caused 10 of the errors.Other fixes
application.pyimportsGraphicsAPIfrompyglet.enumsandOpenGLUserConfigfrompyglet.config.gl, instead of their private re-exports.UIDropdown's overlay:add_option()returns the type it's given, sobutton.on_clicktype checks.UIRenderGroup.scaleis annotated asfloat | tuple[float, float]. It still shadowsUIWidget.scale()on purpose.Window.camerareturns arcade'sDefaultProjector, not a pyglet camera, so its override is ignored with a comment.context.py;algo_detailedfallback type inhitbox;type: ignoresyntax in the CLI;_clean_dictskey type (its dicts have int and str keys).Easingused as a type,Nonesprite lists, and int endpoints;sprite_bullets_sweepannotations;numpy, which onlynumpy_spriteuses and isn't a dependency.Tests
InputManager.parse()round trip: serialize, parse, and compare. Mappings are kept in sets, so the comparison ignores order.pixelated_ui()sets nearest font filtering. Global settings are restored afterwards.window.cameraraises the new error, andwindow.camerastays the default camera.All three fail on
developmentand pass here.I ran every example I changed, plus the lights tutorial and perspective_parallax, for one frame in a hidden window. All ran. With the old
07_camera.py, the same check fails.make.py mypyandmake.py pyrightexit with 1 when there's an error, so CI will fail on them. Locally:uv run mypy arcade: no issues in 402 files.uv run pyright: 0 errors.The changelog has the three crashes under Unreleased → Fixes, and the CI change under Misc Changes.
🤖 Generated with Claude Code