Skip to content

Add Pyright to GitHub Actions CI#18345

Merged
SaschaCowley merged 7 commits intomasterfrom
pyrightCI
Jun 27, 2025
Merged

Add Pyright to GitHub Actions CI#18345
SaschaCowley merged 7 commits intomasterfrom
pyrightCI

Conversation

@SaschaCowley
Copy link
Copy Markdown
Member

@SaschaCowley SaschaCowley commented Jun 26, 2025

Link to issue number:

Closes #17794

Summary of the issue:

Currently, pyright is not running as part of Pre-commit CI, GitHub Actions CI, or Appveyor.

Description of user facing changes:

None.

Description of developer facing changes:

Pyright static type analysis now happens as part of CI/CD.

There is now only one pyright action as part of pre-commit, and it is skipped on pre-commit CI.

Description of development approach:

  • Create a power shell script to run pyright and append its output to the GitHub step summary on failure.

    Add a job to testAndPublish.yml that runs this script.

    Note the job relies on build NVDA as COM Interfaces may be used as part of type analysis, but are built by SCons.

  • Update type annotations in the SAPI4 driver to fix a Pyright error

  • Add tool.pyright.ignore to pyproject.toml with just .venv in it, to prevent Pyright flagging typing errors in dependencies.

Testing strategy:

Check workflows on PR.

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@coderabbitai summary

@seanbudd
Copy link
Copy Markdown
Member

This might have neater output but might not work with our uv setup https://github.com/jordemort/action-pyright

@SaschaCowley SaschaCowley marked this pull request as ready for review June 27, 2025 02:01
Copilot AI review requested due to automatic review settings June 27, 2025 02:01
@SaschaCowley SaschaCowley requested a review from a team as a code owner June 27, 2025 02:01
@SaschaCowley SaschaCowley requested a review from seanbudd June 27, 2025 02:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates Pyright static type analysis into the CI/CD pipeline by introducing a dedicated GitHub Actions job and a PowerShell script to execute and report Pyright results. Key changes include:

  • Adding the SynthCommand import and appropriate type annotations in the SAPI4 driver.
  • Configuring Pyright to ignore specific directories via pyproject.toml.
  • Creating a new PowerShell script and integrating it into the CI workflow, along with adjusting pre-commit settings.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
source/synthDrivers/sapi4.py Added SynthCommand in import list and updated type annotation for supportedCommands.
pyproject.toml Added ignore setting to exclude the .venv directory from Pyright analysis.
ci/scripts/tests/typeCheck.ps1 Created a new script to run Pyright and append its output to the GitHub step summary on failure.
.pre-commit-config.yaml Updated configuration to skip Pyright in pre-commit CI.
.github/workflows/testAndPublish.yml Added a new job that runs the Pyright type check as part of the CI workflow.
Comments suppressed due to low confidence (1)

ci/scripts/tests/typeCheck.ps1:3

  • [nitpick] Consider adding a brief comment explaining the use of 'uv run pyright' instead of calling Pyright directly, to aid future maintainers in understanding this choice.
$pyrightOutput = (uv run pyright) -Join "`n"

Copy link
Copy Markdown
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks

@SaschaCowley SaschaCowley merged commit 28b5d04 into master Jun 27, 2025
19 checks passed
@SaschaCowley SaschaCowley deleted the pyrightCI branch June 27, 2025 04:38
@github-actions github-actions bot added this to the 2025.3 milestone Jun 27, 2025
seanbudd added a commit that referenced this pull request Jul 30, 2025
Link to issue number:

Fixup of #18554
Summary of the issue:

#18345 was missed from #18554 as pyright checks were not on beta, and #18554 was targeted to beta
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.

Fix up pyright on pre-commit CI

3 participants