Skip to content
Snippets Groups Projects
Commit 706c4c27 authored by nimrod's avatar nimrod
Browse files

Fix some pre-commit warnings.

From the updated hooks.
parent ef8ef3d4
No related branches found
No related tags found
No related merge requests found
Pipeline #3697 failed
"""pre-commit hooks package."""
...@@ -7,7 +7,7 @@ import sys ...@@ -7,7 +7,7 @@ import sys
import hooks.utils import hooks.utils
def packer_fix(file): def packer_fix(file): # noqa: D213
"""Runs packer fix. """Runs packer fix.
If the invocation succeeds, overwrite the file with the fixed output from If the invocation succeeds, overwrite the file with the fixed output from
......
...@@ -6,7 +6,7 @@ import sys ...@@ -6,7 +6,7 @@ import sys
import hooks.utils import hooks.utils
def packer_validate(file): def packer_validate(file): # noqa: D213
"""Validate a Packer template. """Validate a Packer template.
Run init when needed. Run init when needed.
......
# noqa: D213
"""Utilities for Python hooks. """Utilities for Python hooks.
Mainly, executing external processes. Mainly, executing external processes.
...@@ -11,14 +12,17 @@ import subprocess # nosec ...@@ -11,14 +12,17 @@ import subprocess # nosec
import sys import sys
def unique_directories(files): def unique_directories(files): # noqa: D213
"""Returns a list of directories (pathlib.Path objects) for the files """Returns the directories of the given files.
passed without repetitions."""
Returns a unique (not repeating) list of the base directories (pathlib.Path
objects) for the list of files given.
"""
return list({pathlib.Path(x).parent for x in files}) return list({pathlib.Path(x).parent for x in files})
@contextlib.contextmanager @contextlib.contextmanager
def chdir(path): def chdir(path): # noqa: D213
"""Context manager for changing the working directory. """Context manager for changing the working directory.
>>> import os >>> import os
...@@ -64,8 +68,11 @@ def check_file(args, file=None): ...@@ -64,8 +68,11 @@ def check_file(args, file=None):
return proc.returncode return proc.returncode
def check_directory(args, directory): def check_directory(args, directory): # noqa: D213
"A simple check for a directory, may be used to build more complex checks." """A simple check for a directory.
May be used to build more complex checks.
"""
with chdir(directory): with chdir(directory):
proc = run(args) proc = run(args)
if proc.returncode > 0: if proc.returncode > 0:
...@@ -74,7 +81,7 @@ def check_directory(args, directory): ...@@ -74,7 +81,7 @@ def check_directory(args, directory):
return proc.returncode return proc.returncode
def bulk_check(checker, items): def bulk_check(checker, items): # noqa: D213
"""Bulk check files. """Bulk check files.
Some programs can only accept a single file or directory to process at a Some programs can only accept a single file or directory to process at a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment