Skip to content

Migrating from pyright to pyrefly for pre-commit silently turns off type checking for files outside include/project-includes #8

@rchen152

Description

@rchen152

If you migrate from pyrefly to pyright for pre-commit, it's very easy to accidentally turn off type checking for some directories. Here's a toy set-up, based on the set-up of a real-world project (pytorch/helion). Essentially, my project has two directories, foo and bar, and the type-checking config says to check only foo:

test/
|--pyproject.toml
|--.pre-commit-config.yaml
|--foo/
|--bar/

Here's the contents of pyproject.toml:

[tool.pyright]
include = ["foo"]

[tool.pyrefly]
project-includes = ["foo"]

And the contents of .pre-commit-config.yaml:

repos:
-   repo: https://github.com/facebook/pyrefly-pre-commit
    rev: 0.0.1
    hooks:
      - id: pyrefly-typecheck-system
        name: Pyrefly (type checking)

-   repo: https://github.com/RobertCraigie/pyright-python
    rev: v1.1.407
    hooks:
      - id: pyright
        language: system

Running either pyright or pyrefly check inside test produces the same behavior: foo is checked. However, running pre-commit run --all-files causes pyright to check all files as specified, including the contents of bar. Pyrefly still checks only foo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions