Skip to content

Use pyrefly for type checking#1143

Merged
oulgen merged 12 commits intopytorch:mainfrom
rchen152:pyrefly
Nov 18, 2025
Merged

Use pyrefly for type checking#1143
oulgen merged 12 commits intopytorch:mainfrom
rchen152:pyrefly

Conversation

@rchen152
Copy link
Copy Markdown
Contributor

This PR switches the type checker for helion from pyright to pyrefly. Benefits of switching:

  • Faster local type checking: in testing on my machine, a full check with pyright takes about 25s, while a full check with pyrefly takes <2s [1].
  • Faster CI: the pre-commit step of lint.yml currently takes about 30s to run [2]; a run on this PR took only 16s [3].
  • Fewer error suppressions: helion previously needed 405 # pyright: ignore directives; only 340 # pyrefly: ignore directives are needed.

The bulk of this PR is a mechanical removal of pyright suppressions and addition of pyrefly suppressions. The interesting changes are:

  • rchen152@1528287 changes the type checker from pyright to pyrefly.
  • rchen152@b718906 adds some type annotations to help pyrefly and removes some typing.cast calls that are no longer needed.
  • rchen152@a085515 removes some search paths that pyright was using (?) that pyrefly can't find.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2025
Copy link
Copy Markdown
Contributor

@oulgen oulgen left a comment

Choose a reason for hiding this comment

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

also update agents.md


- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.407
- repo: https://github.com/facebook/pyrefly-pre-commit
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we use the pyrefly with the version in the config? i think @lolpack added something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried switching to the second option here that's supposed to let you specify the version, but I couldn't get it to work. Pyrefly starts producing a lot of import errors (on torch, triton, etc.) that suggest it's no longer able to find dependencies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I opened an issue against pyrefly-pre-commit: facebook/pyrefly-pre-commit#7.

@oulgen oulgen merged commit d97c978 into pytorch:main Nov 18, 2025
16 checks passed
@rchen152
Copy link
Copy Markdown
Contributor Author

Woohoo! @oulgen thanks for the speedy review

@rchen152 rchen152 deleted the pyrefly branch November 18, 2025 00:42
rchen152 added a commit to rchen152/helion that referenced this pull request Dec 3, 2025
This is a follow-up to a reviewer request in
pytorch#1143 to use an isolated
environment for the pyrefly pre-commit hook. Unfortunately, I
don't think that's practical to do (see
facebook/pyrefly-pre-commit#7 (comment)).
But in the process of looking into this, I ended up giving the
hook a better name and versioning system, which this PR updates
helion's pre-commit config to use.
umechand-amd pushed a commit to umechand-amd/helion that referenced this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants