Skip to content

Commit

Permalink
Add pre-commit hook for safety
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Nov 13, 2020
1 parent 508c075 commit ff624d7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,8 @@ repos:
- id: dep_checker
args:
- repo_helper

- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
sha: v1.1.3
hooks:
- id: python-safety-dependencies-check
7 changes: 7 additions & 0 deletions repo_helper/files/pre_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def to_dict(self) -> MutableMapping[str, Union[str, List[Hook]]]:
hooks=["remove-crlf", "forbid-crlf"],
)

safety = Repo(
repo=make_github_url("Lucas-C", "pre-commit-hooks-safety"),
rev="v1.1.3",
hooks=["python-safety-dependencies-check"],
)

# shellcheck = Repo(
# repo=make_github_url("shellcheck-py", "shellcheck-py"),
# rev="v0.7.1.1",
Expand Down Expand Up @@ -285,6 +291,7 @@ def make_pre_commit(repo_path: pathlib.Path, templates: jinja2.Environment) -> L
pygrep_hooks,
pyupgrade,
lucas_c_hooks,
safety,
yapf_isort,
dep_checker,
]
Expand Down
1 change: 1 addition & 0 deletions repo_helper/files/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def testenv_lint(self):
``[testenv:lint]``.
"""

# TODO: https://github.com/asottile/yesqa
self._ini["testenv:lint"]["basepython"] = "python{min_py_version}".format(**self._globals)
self._ini["testenv:lint"]["changedir"] = "{toxinidir}"
self._ini["testenv:lint"]["ignore_errors"] = True
Expand Down
5 changes: 5 additions & 0 deletions tests/test_files/test_testing_/test_make_pre_commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ repos:
- id: remove-crlf
- id: forbid-crlf

- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: v1.1.3
hooks:
- id: python-safety-dependencies-check

- repo: https://github.com/domdfcoding/yapf-isort
rev: v0.5.1
hooks:
Expand Down

0 comments on commit ff624d7

Please sign in to comment.