Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre commit won't find my pyrightconfig.json settings #291

Open
Aydin-ab opened this issue Aug 28, 2024 · 1 comment
Open

pre commit won't find my pyrightconfig.json settings #291

Aydin-ab opened this issue Aug 28, 2024 · 1 comment

Comments

@Aydin-ab
Copy link

Hello, I've just started using pyright and pre-commit so everything is still new to me and I'm aware the issue is probably because of my inexperience.

My project folder looks like that:

project/
    .pre-commit-config.yaml
    pyrightconfig.json
    repo1/
    repo2/
        src/
            module1.py
            module2.py
            ...

I want pyright to run only on the staged modules that are located at project/repo2/src/utils/ and nowhere else.

My pyrightconfig.json is

{
  "include": [
    "repo2/src"
  ],
  "typeCheckingMode": "strict"
}

My .pre-commit-config.yaml:

repos:
  - repo: https://github.com/RobertCraigie/pyright-python
    rev: v1.1.377
    hooks:
    - id: pyright
      name: pyright
      language: system
      entry: pyright
      types: [python]
      args: ["--project", "pyrightconfig.json", "--verbose"]
      # args: ["--project=pyrightconfig.json", "--verbose"]  # Tried this too
      

If I run pyright at the project root, I get what I want. If I run pre-commit run pyright I don't get the same behavior at all. The verbose arguments aren't even read. The files that are selected are all the ones in the staged, but I want to restrict pyright on the ones at repo2/src/ only

I guess my real question is: How do I make pre-commit run pyright behave as if I'm running pyright in my own conda environment at the project/ location

@pantafive
Copy link

Check that the .git directory is in the root of the project, not at a higher level. Shold be:

project/
    .pre-commit-config.yaml
    pyrightconfig.json
    .git/
    repo1/
    repo2/
        src/
            module1.py
            module2.py

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

No branches or pull requests

2 participants