Skip to content

Commit 6e45252

Browse files
committed
[WIP] Also match .pyi files when looking for .py files
This will make sure that Python-related hints for contributors and pre-commit hooks even if repos only contain stub files [1]. The main motivation behind creating this commit is to prepare for a future commit that will add Python stub files to this repo. That future commit will add wcwidth [2] as a dependency. Unfortunately, wcwidth doesn’t have any type hints yet [3], and there doesn’t seem to be a PEP 561 [4] stub package for wcwidth. When a module isn’t typed and there’s no stub package for that module, mypy’s recommendation is to write your own stub files [5]. As a result, that future commit is going to add .pyi files to this repo. Since that future commit is going to add a new type of file to this repo, I thought that it would make sense to preemptively add support for that file type to repo-style-checker. [1]: <https://mypy.readthedocs.io/en/stable/stubs.html> [2]: <https://pypi.org/project/wcwidth/> [3]: <jquast/wcwidth#71> [4]: <https://peps.python.org/pep-0561/> [5]: <https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker> TODO: • Add the future wcwidth-related commit.
1 parent 02a4fef commit 6e45252

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

jasons_pre_commit_hooks/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"""
6666

6767

68+
PYTHON_GLOBS: Final = ('**.py', '**.pyi')
6869
YAML_GLOBS: Final = ('**.yml', '**.yaml')
6970

7071

@@ -106,7 +107,7 @@
106107
(('.pre-commit-config.yaml',), HFC_PRE_COMMIT_LINKS),
107108
(('.editorconfig',), HFC_EDITOR_CONFIG),
108109
(('**.md',), HFC_MARKDOWN),
109-
(('**.py',), HFC_RUFF)
110+
(PYTHON_GLOBS, HFC_RUFF)
110111
)
111112

112113
# Pre-commit hooks shouldn’t mess with the files in the LICENSES/
@@ -199,14 +200,14 @@ class PreCommitRepoInfo(NamedTuple):
199200
(('.pre-commit-hooks.yaml',), PCR_PRE_COMMIT_UPDATE),
200201
(('.editorconfig',), PCR_EDITORCONFIG_CHECKER),
201202
(('**',), PCR_OFFICIAL_HOOKS),
202-
(('**.py',), PCR_OFFICIAL_HOOKS_PYTHON),
203+
(PYTHON_GLOBS, PCR_OFFICIAL_HOOKS_PYTHON),
203204
(('**',), PCR_PYGREP_HOOKS),
204205
(('**',), PCR_GITLEAKS),
205206
(('**.toml',), PCR_LANGUAGE_FORMATTERS),
206207
(YAML_GLOBS, PCR_YAMLLINT),
207208
(('**.md',), PCR_MARKDOWNLINT_CLI),
208-
(('**.py',), PCR_MYPY),
209-
(('**.py',), PCR_RUFF),
209+
(PYTHON_GLOBS, PCR_MYPY),
210+
(PYTHON_GLOBS, PCR_RUFF),
210211
(('.pre-commit-hooks.yaml',), PCR_PRE_COMMIT_ITSELF),
211212
)
212213

0 commit comments

Comments
 (0)