Skip to content

refactor: narrow file-level Pyright suppressions #5161

Description

@chengyongru

Context

PR #5158 enables BasedPyright strict checking across nanobot/. The strict-clean baseline currently contains 31 file-level directives such as:

# pyright: reportMissingTypeStubs=false, reportPrivateUsage=false

A file-level directive also suppresses future diagnostics of that category elsewhere in the same module, so its blast radius grows as the file evolves.

Goal

Gradually replace file-level Pyright suppressions with the narrowest justified alternative while keeping runtime behavior unchanged.

Approach

  • Inventory the 31 current file-level directives and group them by cause: missing third-party stubs, private API usage, heterogeneous tool overrides, generated/dynamic SDK surfaces, and genuinely dead-code diagnostics.
  • Remove suppressions made obsolete by better annotations or public APIs.
  • Prefer a typed adapter, Protocol, local stub, or narrow runtime normalizer when that improves the owning boundary.
  • When suppression remains necessary, prefer a line-level # pyright: ignore[rule] with the smallest possible scope and a clear local reason.
  • Split the work into reviewable subsystem-sized PRs; do not combine it with unrelated runtime refactors.

Acceptance criteria

  • No net increase in file-level Pyright directives.
  • Each retained file-level directive has a documented reason that cannot reasonably be scoped to a line.
  • Converted suppressions remain BasedPyright strict-clean with no global diagnostic downgrade.
  • Closest subsystem tests and the full configured CI matrix stay green.
  • Progress is measurable against the initial baseline of 31 file-level directives.

Non-goals

  • Removing justified line-level suppressions solely to reach zero ignores.
  • Adding behavior changes to satisfy the checker.
  • Maintaining third-party packages' complete type stubs inside nanobot.

Related: #5158

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions