[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2025-12-17 10:27:14 +00:00
parent 5e4fe2c164
commit 46646b779e
3 changed files with 26 additions and 20 deletions

View file

@ -1,15 +1,16 @@
#!/usr/bin/env python3
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
FORBIDDEN = {"a", "an", "the"}
FORBIDDEN = {'a', 'an', 'the'}
def git_ls_python_files():
result = subprocess.run(
["git", "ls-files", "*.py"],
['git', 'ls-files', '*.py'],
capture_output=True,
text=True,
check=True,
@ -20,14 +21,14 @@ def git_ls_python_files():
def is_test_file(path: Path) -> bool:
name = path.name
return (
name.startswith("test_")
or name.startswith("tests_")
or name.endswith("_test.py")
name.startswith('test_') or
name.startswith('tests_') or
name.endswith('_test.py')
)
def has_forbidden_article(path: Path) -> bool:
parts = path.stem.split("_")
parts = path.stem.split('_')
return any(part in FORBIDDEN for part in parts)
@ -37,12 +38,12 @@ def main() -> int:
continue
if has_forbidden_article(path):
print("ERROR: Forbidden article in test filename:")
print('ERROR: Forbidden article in test filename:')
print(path)
return 1
return 0
if __name__ == "__main__":
if __name__ == '__main__':
sys.exit(main())

View file

@ -1,8 +1,11 @@
from __future__ import annotations
import argparse
import os.path
import re
from collections.abc import Sequence
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser()
parser.add_argument('filenames', nargs='*')