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

Run the mypy pre-commit only on staged files #80

Open
julienperichon opened this issue Nov 24, 2023 · 1 comment
Open

Run the mypy pre-commit only on staged files #80

julienperichon opened this issue Nov 24, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@julienperichon
Copy link
Contributor

By default, pre-commit gives only the staged files to each pre-commit command.

However, in Sicarator, we do the following:

  - id: type-check
    name: Type checking (mypy)
    entry: make type-check
    pass_filenames: false
    language: system
    types: [python]
    stages: [commit]

with make type-check as

type-check:
	poetry run mypy src

We could do something like this to run mypy only on staged files:

  - id: type-check
    name: Type checking (mypy)
    entry: mypy
    language: system
    types: [python]
    stages: [commit]

@ywolff What do you think ?

@ywolff ywolff added the documentation Improvements or additions to documentation label Nov 28, 2023
@ywolff
Copy link
Collaborator

ywolff commented Nov 28, 2023

Current behavior is on purpose, because you can break typing of a file foo.py while modifying only another file bar.py, if foo.py imports bar.py (which is not the case for linting or formatting, which are independent between files).
I agree that it can be a bit surprising and should be documented (in the pre-commit config), so I keep the issue open with a "Documentation" label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants