Skip to content

Commit

Permalink
pre-commit replace bandit with ruff (#45)
Browse files Browse the repository at this point in the history
* πŸ”§  add commitizen

* πŸ”§  remove from pre-commit check-ast, , end-of-file-fixer, trailing-whitespace

* πŸ”§  replace bandit with ruff in pre-commit

* 🩹 βœ… ignore S603 flake-bandit error

* πŸ”§ add flake8-simplify
  • Loading branch information
JoseRZapata authored Mar 25, 2024
1 parent 6c37c22 commit f425353
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
9 changes: 4 additions & 5 deletions tests/test_create_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ def test_cookiecutter_make_help(cookies): # type: ignore
"""ensure the make help command runs without error"""
result = cookies.bake()

make_proc = subprocess.Popen(
make_proc = subprocess.run(
["/usr/bin/make"],
shell=False,
shell=False, # noqa: S603
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=result.project_path,
) # nosec
# stdout, stderr are for debuggin
stdout, stderr = make_proc.communicate()
check=True,
)
assert make_proc.returncode == 0
10 changes: 9 additions & 1 deletion {{cookiecutter.repo_name}}/.code_quality/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ select = [
"PL",
# isort
"I",
# flake8-bandit
"S",
# pyupgrade
"UP",
# ruff
"RUF",
# flake8-simplify
"SIM",
# tryceratops
"TRY",
]
ignore = ["E203"]
ignore = [
"E203",
# bandit: Use of `assert` detected
"S101"
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
Expand Down
19 changes: 7 additions & 12 deletions {{cookiecutter.repo_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude_types: [jupyter]
- id: check-yaml
exclude: ^(mkdocs\.yml|{{cookiecutter.repo_name}}/mkdocs\.yml)$
- id: check-case-conflict
- id: debug-statements
- id: detect-private-key
- id: check-merge-conflict
- id: check-ast
- id: check-added-large-files
args: [--maxkb=100000] # 100MB

Expand All @@ -34,14 +30,6 @@ repos:
args:
- --config-file=.code_quality/mypy.ini

- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
hooks:
- id: bandit
args:
- -c
- .code_quality/bandit.yaml

- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
Expand All @@ -50,3 +38,10 @@ repos:
- id: detect-secrets
name: 'detect-secrets-jupyter'
args: ['--exclude-files', '.*[^i][^p][^y][^n][^b]$', '--exclude-lines', '"(hash|id|image/\w+)":.*', ]

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.20.0
hooks:
- id: commitizen
- id: commitizen-branch
stages: [push]

0 comments on commit f425353

Please sign in to comment.