Skip to content

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

Description

@kratsg
  - 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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