Skip to content

Comments

Add pyright type checking to CI workflow#114

Merged
conradbzura merged 3 commits intoreleasefrom
pyright-linting
Feb 21, 2026
Merged

Add pyright type checking to CI workflow#114
conradbzura merged 3 commits intoreleasefrom
pyright-linting

Conversation

@conradbzura
Copy link
Contributor

Summary

Add pyright as the project's static type checker and integrate it into the run-tests CI workflow. Fix type errors surfaced by pyright in the loadbalancer, task dispatch, and worker connection modules.

Closes #106

Proposed changes

CI workflow integration

Add a dedicated "Run linter" step to .github/workflows/run-tests.yaml that executes uv run pyright before the test step. This ensures type errors block the pipeline before tests run.

Pyright configuration

Add pyright as a dev dependency and configure [tool.pyright] in wool/pyproject.toml:

  • Scope analysis to src/ only
  • Exclude __pycache__, build artifacts, tests, and generated protobuf stubs
  • Enable reportMissingImports, disable reportMissingTypeStubs

Type fixes — AsyncIteratorAsyncGenerator

RoundRobinLoadBalancer.dispatch and WorkerConnection.dispatch both yield values, making them async generators. Pyright correctly flags the AsyncIterator annotation as incorrect. Replace with AsyncGenerator in both signatures.

Also fix the TYPE_CHECKING import path in roundrobin.py from wool.runtime.work (package) to wool.runtime.work.task (module) to resolve a circular import that pyright surfaces.

Type fixes — WorkTask.dispatch return narrowing

WorkTask.dispatch returns the generic type var W but the _run() and _stream() helpers return concrete types. Wrap both return sites with cast(W, ...) so pyright can verify the generic contract. Add runtime assertions at the top of _run and _stream to guard the callable type assumption.

Test cases

This change is a CI/tooling addition with no new runtime behavior. Type correctness is validated by pyright itself in CI. The existing test suite verifies that the annotation changes introduce no regressions.

Implementation plan

    • Add pyright to dev dependencies and configure [tool.pyright] in wool/pyproject.toml
    • Add "Run linter" step to .github/workflows/run-tests.yaml
    • Fix AsyncIteratorAsyncGenerator in roundrobin.py and connection.py
    • Fix TYPE_CHECKING import path in roundrobin.py
    • Add cast() calls and runtime assertions in task.py

@conradbzura conradbzura added the cicd CI/CD pipeline changes label Feb 21, 2026
@wool-labs wool-labs bot added the code-change Indicates that a PR should trigger a release label Feb 21, 2026
@conradbzura conradbzura marked this pull request as ready for review February 21, 2026 03:20
Add pyright to dev dependencies and configure it in pyproject.toml
with appropriate include/exclude paths. Excludes protobuf generated
files, test directories, and cli.py scratch module from analysis.
@conradbzura conradbzura changed the base branch from main to release February 21, 2026 03:36
Correct return type annotations and narrowing issues caught by
pyright across the runtime subpackages:

- roundrobin: Use AsyncGenerator instead of AsyncIterator for dispatch
- task: Add casts for generic W return type and runtime assertions
  for callable type narrowing
- connection: Annotate _execute return type and cast the generator
  in dispatch to satisfy AsyncGenerator variance
- pool: Narrow overload 1 discovery parameter to None to prevent
  overlap with the discovery-required overload; add third overload
  for hybrid pools that both spawn local workers and discover
  remote workers
@conradbzura conradbzura merged commit 02ebf2b into release Feb 21, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cicd CI/CD pipeline changes code-change Indicates that a PR should trigger a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pyright type checking to CI workflow

1 participant