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 25, 2023
1 parent b250cc2 commit 1cd3e82
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 95 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
21 changes: 13 additions & 8 deletions src/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@


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_included = set()
for file in files:
Expand Down Expand Up @@ -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 1cd3e82

Please sign in to comment.