Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pre-commit-hooks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
pre-commit-hooks
Commits
706c4c27
Commit
706c4c27
authored
1 year ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
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
1 year ago
Stage: .pre
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
hooks/__init__.py
+1
-0
1 addition, 0 deletions
hooks/__init__.py
hooks/packer_fix.py
+1
-1
1 addition, 1 deletion
hooks/packer_fix.py
hooks/packer_validate.py
+1
-1
1 addition, 1 deletion
hooks/packer_validate.py
hooks/utils.py
+14
-7
14 additions, 7 deletions
hooks/utils.py
with
17 additions
and
9 deletions
hooks/__init__.py
+
1
−
0
View file @
706c4c27
"""
pre-commit hooks package.
"""
This diff is collapsed.
Click to expand it.
hooks/packer_fix.py
+
1
−
1
View file @
706c4c27
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
hooks/packer_validate.py
+
1
−
1
View file @
706c4c27
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
hooks/utils.py
+
14
−
7
View file @
706c4c27
# 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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment