Skip to content

Commit

Permalink
chore(pre-commit): Fix pre-commit error
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalHappiness committed Oct 24, 2023
1 parent 02d909e commit 40ce72f
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ repos:
- --remove-unused-variables
- --remove-all-unused-imports
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
208 changes: 207 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ python = "^3.8"

[tool.poetry.dev-dependencies]
pytest = "^7.4.2"
pre-commit = "2.14.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
23 changes: 14 additions & 9 deletions src/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@


class Missing:

def __init__(self, exclude: Sequence[str]):
if not (isinstance(exclude, list) or isinstance(exclude, tuple)):
raise TypeError('exclude should be list or tuple')
for path in exclude:
if os.path.exists(path) and not os.path.isdir(path):
raise TypeError(f"exclude should only contain directories, found file {path}")
raise TypeError(
f'exclude should only contain directories, found file {path}'
)

files = [os.path.normpath(path) for path in self._list_files()]
logger.debug(f"{files=}")
logger.debug(f'{files=}')

exclude = [os.path.normpath(path) for path in exclude]
logger.debug(f"{exclude=}")
logger.debug(f'{exclude=}')

files_excluded = set()
for file in files:
if all([not file.startswith(e) for e in exclude]):
files_excluded.add(file)
logger.debug(f"{files_excluded=}")
logger.debug(f'{files_excluded=}')

self.files = files_excluded

Expand All @@ -55,10 +56,14 @@ def run(self) -> int:
def _list_files():
pattern = re.compile(r'^.*?\.py$')

files = subprocess.check_output(
['git', 'ls-files', '-z'],
encoding='utf-8',
).rstrip('\0').split('\0')
files = (
subprocess.check_output(
['git', 'ls-files', '-z'],
encoding='utf-8',
)
.rstrip('\0')
.split('\0')
)

files += (
subprocess.check_output(
Expand Down
Loading

0 comments on commit 40ce72f

Please sign in to comment.