mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-04 03:06:54 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
5e4fe2c164
commit
46646b779e
3 changed files with 26 additions and 20 deletions
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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='*')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue