Harden mypy/ruff tooling and improve typing#951
Open
Carreau wants to merge 1 commit into
Open
Conversation
Toolchain: - Bump pinned linters to what CI actually enforces: ruff 0.2.0 -> 0.15.8 and mypy 1.8.0 -> 1.18.2. The old mypy pin masked errors that the already-declared test-dependency range (>=1.17,<1.19) reports; the code now passes cleanly under both 1.18.2 and 1.19. - Enable additional mypy error codes: truthy-iterable, possibly-undefined, redundant-self, unused-awaitable. - Drop ruff rules removed upstream (UP038, PT004, PT005); ignore PLC0415 (traitlets relies on lazy/optional imports); relax RUF059/PLW0108/B024 for tests, matching the existing per-file test allowances. Typing / correctness: - parse_notifier_name / observe / unobserve: Iterable -> Collection, so the `not names` / `All in names` checks are honest (a generator was a latent bug) and truthy-iterable is satisfied. - SingletonConfigurable.instance now returns Self instead of a bespoke TypeVar (PYI019). - _CallbackWrapper gets a __hash__ consistent with __eq__ (PLW1641). - Use `is` instead of `==` for exact trait-type comparisons (E721). - Correct/remove stale `type: ignore` codes and unused noqa directives. Cleanups: - Modernize %-formatting and str.format to f-strings (UP031/UP032). - Replace dict-index iteration with .items() (PLC0206), iterable unpacking (RUF005), and lazy %-args for a logging call (G004). - Reformat with the newer ruff-format. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TBmDBHmq8vVSGig4i37KK7
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.
Toolchain:
and mypy 1.8.0 -> 1.18.2. The old mypy pin masked errors that the
already-declared test-dependency range (>=1.17,<1.19) reports; the code
now passes cleanly under both 1.18.2 and 1.19.
redundant-self, unused-awaitable.
(traitlets relies on lazy/optional imports); relax RUF059/PLW0108/B024
for tests, matching the existing per-file test allowances.
Typing / correctness:
not names/All in nameschecks are honest (a generator was a latentbug) and truthy-iterable is satisfied.
TypeVar (PYI019).
isinstead of==for exact trait-type comparisons (E721).type: ignorecodes and unused noqa directives.Cleanups:
(RUF005), and lazy %-args for a logging call (G004).
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01TBmDBHmq8vVSGig4i37KK7