cookie icon indicating copy to clipboard operation
cookie copied to clipboard

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

Open kratsg opened this issue 11 months ago • 1 comments

  - 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 https://github.com/pre-commit/pre-commit/issues/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

kratsg avatar Jan 22 '25 04:01 kratsg

https://github.com/scientific-python/repo-review/blob/1a277efd2f08ca178339ff7441e52604b19ba1c2/pyproject.toml#L165 should do it.

henryiii avatar Jan 22 '25 04:01 henryiii