Skip to content

Harden mypy/ruff tooling and improve typing#951

Open
Carreau wants to merge 1 commit into
mainfrom
claude/mypy-ruff-typing-hardening-66g4r3
Open

Harden mypy/ruff tooling and improve typing#951
Carreau wants to merge 1 commit into
mainfrom
claude/mypy-ruff-typing-hardening-66g4r3

Conversation

@Carreau

@Carreau Carreau commented Jul 16, 2026

Copy link
Copy Markdown
Member

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

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

2 participants