Skip to content

Commit 5a772dd

Browse files
committed
Made Bandit exclude test dirs
This removes the need for the `nosec` comments in files inside those directories. Also, the existing `-x` arg doesn't seem to work anymore, so this fixes that.
1 parent 38ec0c2 commit 5a772dd

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ repos:
44
rev: 1.7.7
55
hooks:
66
- id: bandit
7-
args:
8-
- "-x *test*.py"
7+
exclude: /.*tests/
98

109
- repo: https://github.com/psf/black-pre-commit-mirror
1110
rev: 24.2.0

simple_history/registry_tests/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def get_history(model):
5151

5252
self.assertRaises(AttributeError, get_history, User)
5353
self.assertEqual(len(User.histories.all()), 0)
54-
user = User.objects.create(username="bob", password="pass") # nosec
54+
user = User.objects.create(username="bob", password="pass")
5555
self.assertEqual(len(User.histories.all()), 1)
5656
self.assertEqual(len(user.histories.all()), 1)
5757

simple_history/tests/generated_file_checks/check_translations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import subprocess # nosec
1+
import subprocess
22
import sys
33
from glob import glob
44
from pathlib import Path
@@ -44,12 +44,12 @@ def main():
4444
call_command("compilemessages")
4545

4646
log("\nRunning 'git status'...")
47-
result = subprocess.run( # nosec
47+
result = subprocess.run(
4848
["git", "status", "--porcelain"],
4949
check=True,
5050
stdout=subprocess.PIPE,
5151
)
52-
assert result.stderr is None # nosec
52+
assert result.stderr is None
5353
stdout = result.stdout.decode()
5454
if stdout:
5555
log_err(f"Unexpected changes found in the workspace:\n\n{stdout}")
@@ -61,7 +61,7 @@ def main():
6161
sys.exit(1)
6262
else:
6363
# Print the human-readable status to the console
64-
subprocess.run(["git", "status"]) # nosec
64+
subprocess.run(["git", "status"])
6565

6666

6767
if __name__ == "__main__":

simple_history/tests/tests/test_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,7 @@ class MultiDBExplicitHistoryUserIDTest(TestCase):
24622462
databases = {"default", "other"}
24632463

24642464
def setUp(self):
2465-
self.user = get_user_model().objects.create( # nosec
2465+
self.user = get_user_model().objects.create(
24662466
username="username", email="username@test.com", password="top_secret"
24672467
)
24682468

@@ -2503,10 +2503,10 @@ def test_history_user_does_not_exist(self):
25032503

25042504
class RelatedNameTest(TestCase):
25052505
def setUp(self):
2506-
self.user_one = get_user_model().objects.create( # nosec
2506+
self.user_one = get_user_model().objects.create(
25072507
username="username_one", email="first@user.com", password="top_secret"
25082508
)
2509-
self.user_two = get_user_model().objects.create( # nosec
2509+
self.user_two = get_user_model().objects.create(
25102510
username="username_two", email="second@user.com", password="top_secret"
25112511
)
25122512

0 commit comments

Comments
 (0)