Skip to content

Add Pyright CI workflow#3647

Closed
correctmost wants to merge 7 commits intoarchlinux:masterfrom
correctmost:cm/add-pyright-checks
Closed

Add Pyright CI workflow#3647
correctmost wants to merge 7 commits intoarchlinux:masterfrom
correctmost:cm/add-pyright-checks

Conversation

@correctmost
Copy link
Copy Markdown
Contributor

PR Description:

I'm submitting a draft PR to see if there's interest in additional CI checks.

I use Pyright locally because it sometimes finds issues that are missed by mypy, ruff, and Pylint. Pyright also has some checks that are not present in other tools, like reportImportCycles.

Benefits:

  • Pyright can catch issues missed by other type checkers and static analysis tools. This seems particularly useful now that AI-generated contributions are becoming more common.
  • Pyright can help improve code quality and code architecture by enabling checks like reportUnnecessaryComparison and reportImportCycles
  • Adding the Pyright configuration to pyproject.toml provides better on-the-fly IDE checks for developers who use VS Code + Pyright/Pylance
  • Adding the Pyright configuration will also help catch regressions in Pyright because archinstall is included in mypy_primer, which is run on every Pyright PR

Drawbacks:

  • It can be annoying to appease multiple type checkers. This may become even harder if there's interest in using ty or Pyrefly once they are ready for production use.
  • Running Pyright locally and inside pre-commit requires Node.js to be installed

@correctmost correctmost force-pushed the cm/add-pyright-checks branch 2 times, most recently from d862119 to 2b72b61 Compare June 30, 2025 23:40
@correctmost correctmost force-pushed the cm/add-pyright-checks branch from 2b72b61 to bbfbb55 Compare July 21, 2025 19:26
@correctmost correctmost force-pushed the cm/add-pyright-checks branch from bbfbb55 to 0ce13f6 Compare August 5, 2025 16:01
@Torxed
Copy link
Copy Markdown
Member

Torxed commented Aug 6, 2025

Running Pyright locally and inside pre-commit requires Node.js to be installed

I think this was the only thing that made me a bit worried.
If we can exclude it from pre-commit, or make it optional, that would be great.
Personally I wouldn't like to drag Node.js into my machine if I can help it heh.

On the github runners tho, that's fine!

@correctmost correctmost marked this pull request as ready for review August 10, 2025 07:03
@correctmost correctmost requested a review from Torxed as a code owner August 10, 2025 07:03
@correctmost
Copy link
Copy Markdown
Contributor Author

If we can exclude it from pre-commit, or make it optional, that would be great.
Personally I wouldn't like to drag Node.js into my machine if I can help it heh.

That's understandable :).

I am okay with leaving Pyright out of pre-commit and seeing how things go with the CI checks. If the checks become burdensome, we can revisit whether it makes sense to keep them.

@correctmost correctmost force-pushed the cm/add-pyright-checks branch from 0ce13f6 to 7c87a31 Compare August 10, 2025 07:14
@svartkanin
Copy link
Copy Markdown
Collaborator

Does this https://github.com/RobertCraigie/pyright-python?tab=readme-ov-file#pre-commit actually need node though?
I tried out adding it to the .pre-commit-config.yaml file

  - repo: https://github.com/RobertCraigie/pyright-python
    rev: v1.1.403
    hooks:
    - id: pyright

and it seems to work, despite that I don't have node installed

@correctmost
Copy link
Copy Markdown
Contributor Author

Does this https://github.com/RobertCraigie/pyright-python?tab=readme-ov-file#pre-commit actually need node though?

If you don't have node installed, pyright-python will download a pre-built node binary using nodeenv:

$ du -sh ~/.cache/pyright-python/
420M	/home/user/.cache/pyright-python/

I'm not sure if people are okay with that happening behind the scenes :).

@correctmost correctmost force-pushed the cm/add-pyright-checks branch from 7c87a31 to c1748d9 Compare August 12, 2025 20:50
@svartkanin
Copy link
Copy Markdown
Collaborator

Not sure what the concern would be? The downloaded version is only part of the pyright installation and not a system installation no?

It'd get frustrating if GH actions keep failing because the changes weren't validated locally first...

@correctmost
Copy link
Copy Markdown
Contributor Author

Not sure what the concern would be? The downloaded version is only part of the pyright installation and not a system installation no?

Yeah, it would just be a local installation that isn't visible to any package managers.

I think some developers avoid Node.js because of ongoing security issues with packages in the npm repository. Other package managers have similar issues, but the npm ones seem a bit more pervasive.

Aside from that, the various caches and downloads from pre-commit are not automatically cleaned up, so you can end up accumulating files in ~/.cache/pre-commit/ and ~/.cache/pyright-python/.

It'd get frustrating if GH actions keep failing because the changes weren't validated locally first...

Agreed. I'm not sure if there's a good way to make certain pre-commit hooks optional either.

@correctmost correctmost force-pushed the cm/add-pyright-checks branch from c1748d9 to 2eff176 Compare August 21, 2025 18:52
@correctmost
Copy link
Copy Markdown
Contributor Author

Closing this for now. I think additional workflows can be reassessed after ty and Pyrefly (and maybe zuban?) are stabilized.

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.

3 participants