Skip to content

Wire up pyright: config, fix outstanding errors, run it in CI #30

Description

@khusmann

Typechecking isn't wired into the repo, so errors only surface if you happen to run pyright by hand against the right interpreter. Nothing runs on PRs either — docs.yml and publish-release.yml are both push-triggered.

  • Add pyrightconfig.json (include: ["src", "tests"], pin typeCheckingMode)
  • Fix the errors strict currently reports (below)
  • Add make typecheck / make test
  • Add a CI workflow running both on PRs
  • Consider a dev extra in pyproject.toml so pytest and pyright versions are pinned

Current strict output

With {"include": ["src", "tests"], "typeCheckingMode": "strict"}:

src/benlink/protocol/command/bitfield.py:564 - Type "(Any) -> ..." is not assignable to declared type
src/benlink/protocol/command/bitfield.py:568 - Argument of type ... cannot be assigned to parameter "fn"
src/benlink/protocol/command/bitfield.py:570 - Type "(Any, int) -> ..." is not assignable to declared type
src/benlink/protocol/command/bitfield.py:575 - Argument of type ... cannot be assigned to parameter "fn"
tests/test_firmware.py:171 - "_resolve_product" is private and used outside of the module in which it is declared (reportPrivateUsage)

The four bitfield.py ones are all the same thing: bf_dyn accepts either a 1-arg or 2-arg discriminator, and the union isn't assignable to BFType's single signature. Wants either a real fix or a targeted ignore.

The test one just needs _resolve_product made public or ignored at the call site.

Note on interpreter selection

Worth having the config make the intended interpreter unambiguous. With the wrong env active the editor reports missing-import errors for pytest/benlink that have nothing to do with the code, which is easy to misread as a broken install.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions