Skip to content

Fix the ruff errors in the tests - #2939

Merged
pvcraven merged 1 commit into
developmentfrom
tests/ruff-cleanup
Oct 7, 2026
Merged

pvcraven merged 1 commit into
developmentfrom
tests/ruff-cleanup

Conversation

@pvcraven

@pvcraven pvcraven commented Oct 7, 2026

Copy link
Copy Markdown
Member

Summary

Fixes all 79 ruff errors in tests/. The tests are in ruff's lint.exclude in pyproject.toml, so CI never reported these. They only show when you run ruff check tests.

Rule Count Fix
F401 unused import 22 Removed with ruff --fix. I checked every removed line: none were fixtures, which ruff can't see being used.
F403/F405 star import 22 test_math.py: replaced from arcade.math import * with the 12 names it uses. test_arcade.py: kept, with # noqa: F403, since checking what from arcade import * gives you is what that test does.
F841 unused variable 20 See below.
E501 line too long 9 Wrapped. Expected strings are split with implicit concatenation, so their values are unchanged, and the 64-byte matrix literal is now one row per line.
W605, E713, E712 4 Raw string for a regex, not in, and == False → is False.
F811 redefinition 2 Found a real problem in a test; see below.

Unused variables, decided case by case:

  • Assignments inside pytest.raises blocks, or that only checked a call works: dropped the assignment and kept the call.
  • test_gl_gc.py: it holds a reference on purpose, then drops it with = None to trigger garbage collection. That's now del, which says the same thing more clearly.
  • Only used by commented-out code: removed.
  • test_spritesequence.py: two annotated assignments are deliberate type checks (# assert_type), so they're marked with noqa.

A real problem in test_event_order.py: the test defined two window handlers both named record_window, so the second replaced the first. At the end, window.remove_handler("on_mouse_press", record_window) passed the release handler, which pyglet silently ignores ("No error is raised if any handler does not appear"). So neither handler was removed from the window that later tests share. They now have distinct names, and both are removed.

Checks

  • ruff check tests: all checks pass.
  • Full suite: 1732 passed.
  • ruff format: the two files I edited are formatted. Two other test files were already unformatted on development (test_ubo_stress.py, image_compare.py), and I left them alone.

No library code changes, so there's no changelog entry.

Possible follow-up: removing "tests" from lint.exclude would make CI lint the tests from now on, so they stay clean. I left that out, since it's a project decision.

🤖 Generated with Claude Code

The tests are excluded from ruff's lint settings, so these weren't
reported. Fix all 79:

- Remove 22 unused imports (none were fixtures).
- Replace `from arcade.math import *` in test_math.py with the names it
  uses. test_arcade.py keeps its star import, which is what it tests.
- Unused variables: drop assignments that only checked a call raised or
  worked; use `del` in the GC test, which drops references on purpose;
  remove ones only used by commented out code; mark the annotated
  assignments in test_spritesequence.py that check types.
- test_event_order.py defined two handlers named `record_window`, so the
  test removed the release handler as the press handler, and neither was
  removed from the shared window. Name them apart and remove both.
- Wrap long lines, fix two invalid escape sequences, `not in`, and an
  `== False` comparison.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pvcraven
pvcraven merged commit 55a1503 into development Oct 7, 2026
7 checks passed
@pvcraven
pvcraven deleted the tests/ruff-cleanup branch October 7, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant