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

suggestion: update mypy pre-commit configuration to always pass in all files #538

Open
kratsg opened this issue Jan 22, 2025 · 1 comment

Comments

@kratsg
Copy link
Contributor

kratsg commented Jan 22, 2025

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: "v1.11.1"
    hooks:
      - id: mypy
        files: src|tests
        args: []
        additional_dependencies:
          - pytest

the issue with this pre-commit configuration is that if you rely on importing your package in tests where your package is defined in src, then mypy is not aware of the package you locally work on unless there are changes in src. The only workaround I've been able to dig up is to always pass in the files into mypy no matter what (see pre-commit/pre-commit#1519):

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: "v1.11.1"
    hooks:
      - id: mypy
        files: src|tests
        pass_filenames: false
        args: []
        additional_dependencies:
          - pytest
@henryiii
Copy link
Collaborator

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