Skip to content

Commit 627fb59

Browse files
authored
fix: improve mypy settings such that it collects all package and test files instead of using the files passed in by pre-commit (#1248)
1 parent fb2e31c commit 627fb59

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ repos:
4949
name: Check typing annotations
5050
entry: mypy
5151
language: python
52-
files: ^src/package/|^tests/
52+
files: ^src/package/|^tests/ # Declare files to run the hook only when necessary.
5353
types: [text, python]
54-
args: [--explicit-package-bases, --config-file, pyproject.toml]
54+
pass_filenames: false
55+
args: [--config-file, pyproject.toml]
5556

5657
# Enable a whole bunch of useful helper hooks, too.
5758
# See https://pre-commit.com/hooks.html for more hooks.

pyproject.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,15 @@ exclude = [
124124

125125
# https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml
126126
[tool.mypy]
127-
# mypy_path =
127+
files = [
128+
"src/package/",
129+
"tests/",
130+
]
128131
# exclude =
132+
mypy_path = [
133+
"src/",
134+
]
135+
explicit_package_bases = true
129136
show_error_codes = true
130137
show_column_numbers = true
131138
pretty = true
@@ -146,11 +153,12 @@ disallow_untyped_decorators = true
146153
# disable_error_code =
147154
# allow_redefinition =
148155

156+
# https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
149157
[[tool.mypy.overrides]]
150158
module = [
151-
"pytest.*",
152159
]
153-
ignore_missing_imports = true
160+
follow_untyped_imports = true
161+
# ignore_missing_imports = true
154162

155163

156164
# https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html

0 commit comments

Comments
 (0)