From aa8a8e82f2af8056a4f72e5f49814f9c02480bc3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 22:35:07 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black-pre-commit-mirror: 25.12.0 → 26.1.0](https://github.com/psf/black-pre-commit-mirror/compare/25.12.0...26.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ee8def79b..fd149bf4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: reorder-python-imports args: [--application-directories, '.:src', --py38-plus] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.12.0 + rev: 26.1.0 hooks: - id: black args: [--line-length=79, --target-version=py38] From 862ed2215327a9f4bd7a1b074b646b47a29aace3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 22:35:38 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- bandit/__main__.py | 1 + bandit/blacklists/calls.py | 1 + bandit/blacklists/imports.py | 1 + bandit/cli/baseline.py | 1 + bandit/cli/config_generator.py | 1 + bandit/cli/main.py | 7 +++---- bandit/core/utils.py | 4 ++-- bandit/formatters/csv.py | 1 + bandit/formatters/custom.py | 1 + bandit/formatters/html.py | 1 + bandit/formatters/json.py | 1 + bandit/formatters/sarif.py | 3 ++- bandit/formatters/screen.py | 1 + bandit/formatters/text.py | 1 + bandit/formatters/utils.py | 1 + bandit/formatters/xml.py | 1 + bandit/formatters/yaml.py | 1 + bandit/plugins/app_debug.py | 1 + bandit/plugins/asserts.py | 1 + .../crypto_request_no_cert_validation.py | 1 + bandit/plugins/exec.py | 1 + bandit/plugins/general_bad_file_permissions.py | 1 + bandit/plugins/general_bind_all_interfaces.py | 1 + bandit/plugins/general_hardcoded_tmp.py | 1 + bandit/plugins/hashlib_insecure_functions.py | 1 + bandit/plugins/huggingface_unsafe_download.py | 1 + bandit/plugins/injection_paramiko.py | 1 + bandit/plugins/injection_sql.py | 1 + bandit/plugins/injection_wildcard.py | 1 + bandit/plugins/jinja2_templates.py | 1 + .../plugins/logging_config_insecure_listen.py | 1 + bandit/plugins/mako_templates.py | 1 + bandit/plugins/markupsafe_markup_xss.py | 1 + bandit/plugins/pytorch_load.py | 1 + bandit/plugins/request_without_timeout.py | 1 + bandit/plugins/ssh_no_host_key_verification.py | 1 + bandit/plugins/tarfile_unsafe_members.py | 1 + bandit/plugins/trojansource.py | 2 +- bandit/plugins/try_except_continue.py | 1 + bandit/plugins/try_except_pass.py | 1 + bandit/plugins/weak_cryptographic_key.py | 1 + bandit/plugins/yaml_load.py | 1 + setup.py | 1 - tests/functional/test_runtime.py | 18 +++++++++--------- tests/unit/core/test_config.py | 18 ++++++------------ tests/unit/core/test_manager.py | 4 +--- tests/unit/core/test_util.py | 2 +- tests/unit/formatters/test_csv.py | 2 +- tests/unit/formatters/test_custom.py | 2 +- tests/unit/formatters/test_html.py | 2 +- tests/unit/formatters/test_json.py | 2 +- tests/unit/formatters/test_sarif.py | 2 +- tests/unit/formatters/test_screen.py | 6 +++--- tests/unit/formatters/test_text.py | 6 +++--- tests/unit/formatters/test_xml.py | 2 +- tests/unit/formatters/test_yaml.py | 2 +- 56 files changed, 76 insertions(+), 47 deletions(-) diff --git a/bandit/__main__.py b/bandit/__main__.py index f43c06a25..24d50dfee 100644 --- a/bandit/__main__.py +++ b/bandit/__main__.py @@ -12,6 +12,7 @@ https://bandit.readthedocs.io/ """ + from bandit.cli import main main.main() diff --git a/bandit/blacklists/calls.py b/bandit/blacklists/calls.py index 024e873a7..b6f3bddd2 100644 --- a/bandit/blacklists/calls.py +++ b/bandit/blacklists/calls.py @@ -339,6 +339,7 @@ +------+---------------------+------------------------------------+-----------+ """ + from bandit.blacklists import utils from bandit.core import issue diff --git a/bandit/blacklists/imports.py b/bandit/blacklists/imports.py index b15155b65..65901724e 100644 --- a/bandit/blacklists/imports.py +++ b/bandit/blacklists/imports.py @@ -227,6 +227,7 @@ +------+---------------------+------------------------------------+-----------+ """ + from bandit.blacklists import utils from bandit.core import issue diff --git a/bandit/cli/baseline.py b/bandit/cli/baseline.py index 406c0c776..dfcf09083 100644 --- a/bandit/cli/baseline.py +++ b/bandit/cli/baseline.py @@ -10,6 +10,7 @@ # reports on any new findings. # ############################################################################# """Bandit is a tool designed to find common security issues in Python code.""" + import argparse import contextlib import logging diff --git a/bandit/cli/config_generator.py b/bandit/cli/config_generator.py index 7564db4f1..c4a49e706 100644 --- a/bandit/cli/config_generator.py +++ b/bandit/cli/config_generator.py @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 """Bandit is a tool designed to find common security issues in Python code.""" + import argparse import importlib import logging diff --git a/bandit/cli/main.py b/bandit/cli/main.py index f489d4533..a11eb6ed4 100644 --- a/bandit/cli/main.py +++ b/bandit/cli/main.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 """Bandit is a tool designed to find common security issues in Python code.""" + import argparse import fnmatch import logging @@ -393,8 +394,7 @@ def main(): blacklist_info.append(f"{b['id']}\t{b['name']}") plugin_list = "\n\t".join(sorted(set(plugin_info + blacklist_info))) - dedent_text = textwrap.dedent( - """ + dedent_text = textwrap.dedent(""" CUSTOM FORMATTING ----------------- @@ -421,8 +421,7 @@ def main(): The following tests were discovered and loaded: ----------------------------------------------- - """ - ) + """) parser.epilog = dedent_text + f"\t{plugin_list}" # setup work - parse arguments, and initialize BanditManager diff --git a/bandit/core/utils.py b/bandit/core/utils.py index 496d48031..871a7355a 100644 --- a/bandit/core/utils.py +++ b/bandit/core/utils.py @@ -136,7 +136,7 @@ def get_module_qualname_from_path(path): :return: fully qualified module name """ - (head, tail) = os.path.split(path) + head, tail = os.path.split(path) if head == "" or tail == "": raise InvalidModulePath( f'Invalid python file path: "{path}" Missing path or file name' @@ -145,7 +145,7 @@ def get_module_qualname_from_path(path): qname = [os.path.splitext(tail)[0]] while head not in ["/", ".", ""]: if os.path.isfile(os.path.join(head, "__init__.py")): - (head, tail) = os.path.split(head) + head, tail = os.path.split(head) qname.insert(0, tail) else: break diff --git a/bandit/formatters/csv.py b/bandit/formatters/csv.py index 6cde187f5..7c1f23107 100644 --- a/bandit/formatters/csv.py +++ b/bandit/formatters/csv.py @@ -27,6 +27,7 @@ New field `CWE` added to output """ + # Necessary for this formatter to work when imported on Python 2. Importing # the standard library's csv module conflicts with the name of this module. import csv diff --git a/bandit/formatters/custom.py b/bandit/formatters/custom.py index e9381ea04..1fce2fde1 100644 --- a/bandit/formatters/custom.py +++ b/bandit/formatters/custom.py @@ -25,6 +25,7 @@ New field `CWE` added to output """ + import logging import os import re diff --git a/bandit/formatters/html.py b/bandit/formatters/html.py index fb09f835f..80e8f4a35 100644 --- a/bandit/formatters/html.py +++ b/bandit/formatters/html.py @@ -146,6 +146,7 @@ New field `CWE` added to output """ + import logging import sys from html import escape as html_escape diff --git a/bandit/formatters/json.py b/bandit/formatters/json.py index 3a954a4dd..f1deae7ae 100644 --- a/bandit/formatters/json.py +++ b/bandit/formatters/json.py @@ -73,6 +73,7 @@ New field `CWE` added to output """ + # Necessary so we can import the standard library json module while continuing # to name this file json.py. (Python 2 only) import datetime diff --git a/bandit/formatters/sarif.py b/bandit/formatters/sarif.py index 5b06ce71d..a24042c39 100644 --- a/bandit/formatters/sarif.py +++ b/bandit/formatters/sarif.py @@ -125,6 +125,7 @@ .. versionadded:: 1.7.8 """ # noqa: E501 + import datetime import logging import pathlib @@ -206,7 +207,7 @@ def add_skipped_file_notifications(skips, invocation): invocation.tool_configuration_notifications = [] for skip in skips: - (file_name, reason) = skip + file_name, reason = skip notification = om.Notification( level="error", diff --git a/bandit/formatters/screen.py b/bandit/formatters/screen.py index 7421c3ea8..34cac3b08 100644 --- a/bandit/formatters/screen.py +++ b/bandit/formatters/screen.py @@ -32,6 +32,7 @@ New field `CWE` added to output """ + import datetime import logging import sys diff --git a/bandit/formatters/text.py b/bandit/formatters/text.py index 932491805..cff56592d 100644 --- a/bandit/formatters/text.py +++ b/bandit/formatters/text.py @@ -32,6 +32,7 @@ New field `CWE` added to output """ + import datetime import logging import sys diff --git a/bandit/formatters/utils.py b/bandit/formatters/utils.py index ebe9f921a..a068e1f73 100644 --- a/bandit/formatters/utils.py +++ b/bandit/formatters/utils.py @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 """Utility functions for formatting plugins for Bandit.""" + import io diff --git a/bandit/formatters/xml.py b/bandit/formatters/xml.py index d2b2067ff..ee7b52f1b 100644 --- a/bandit/formatters/xml.py +++ b/bandit/formatters/xml.py @@ -33,6 +33,7 @@ New field `CWE` added to output """ + import logging import sys from xml.etree import ElementTree as ET # nosec: B405 diff --git a/bandit/formatters/yaml.py b/bandit/formatters/yaml.py index 421109078..4d34f60f3 100644 --- a/bandit/formatters/yaml.py +++ b/bandit/formatters/yaml.py @@ -59,6 +59,7 @@ New field `CWE` added to output """ + # Necessary for this formatter to work when imported on Python 2. Importing # the standard library's yaml module conflicts with the name of this module. import datetime diff --git a/bandit/plugins/app_debug.py b/bandit/plugins/app_debug.py index 3b18996fe..024c24a05 100644 --- a/bandit/plugins/app_debug.py +++ b/bandit/plugins/app_debug.py @@ -41,6 +41,7 @@ CWE information added """ # noqa: E501 + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/asserts.py b/bandit/plugins/asserts.py index b32007c65..2c361a392 100644 --- a/bandit/plugins/asserts.py +++ b/bandit/plugins/asserts.py @@ -52,6 +52,7 @@ CWE information added """ + import fnmatch import bandit diff --git a/bandit/plugins/crypto_request_no_cert_validation.py b/bandit/plugins/crypto_request_no_cert_validation.py index 11791ed1e..4ceb8570f 100644 --- a/bandit/plugins/crypto_request_no_cert_validation.py +++ b/bandit/plugins/crypto_request_no_cert_validation.py @@ -46,6 +46,7 @@ Added check for httpx module """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/exec.py b/bandit/plugins/exec.py index 3e4624780..1737c67fd 100644 --- a/bandit/plugins/exec.py +++ b/bandit/plugins/exec.py @@ -34,6 +34,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/general_bad_file_permissions.py b/bandit/plugins/general_bad_file_permissions.py index 7d3fce4df..e33c028e8 100644 --- a/bandit/plugins/general_bad_file_permissions.py +++ b/bandit/plugins/general_bad_file_permissions.py @@ -53,6 +53,7 @@ Added checks for S_IWGRP and S_IXOTH """ # noqa: E501 + import stat import bandit diff --git a/bandit/plugins/general_bind_all_interfaces.py b/bandit/plugins/general_bind_all_interfaces.py index 58b840e86..7cf57def2 100644 --- a/bandit/plugins/general_bind_all_interfaces.py +++ b/bandit/plugins/general_bind_all_interfaces.py @@ -35,6 +35,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/general_hardcoded_tmp.py b/bandit/plugins/general_hardcoded_tmp.py index ecf899527..7c09f7d84 100644 --- a/bandit/plugins/general_hardcoded_tmp.py +++ b/bandit/plugins/general_hardcoded_tmp.py @@ -51,6 +51,7 @@ CWE information added """ # noqa: E501 + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/hashlib_insecure_functions.py b/bandit/plugins/hashlib_insecure_functions.py index 4b63de1e9..d6e9139a2 100644 --- a/bandit/plugins/hashlib_insecure_functions.py +++ b/bandit/plugins/hashlib_insecure_functions.py @@ -45,6 +45,7 @@ Added check for the crypt module weak hashes """ # noqa: E501 + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/huggingface_unsafe_download.py b/bandit/plugins/huggingface_unsafe_download.py index e51181a41..2add0f3b8 100644 --- a/bandit/plugins/huggingface_unsafe_download.py +++ b/bandit/plugins/huggingface_unsafe_download.py @@ -59,6 +59,7 @@ .. versionadded:: 1.8.6 """ + import string import bandit diff --git a/bandit/plugins/injection_paramiko.py b/bandit/plugins/injection_paramiko.py index 674fe0b9b..fe7813664 100644 --- a/bandit/plugins/injection_paramiko.py +++ b/bandit/plugins/injection_paramiko.py @@ -40,6 +40,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/injection_sql.py b/bandit/plugins/injection_sql.py index 704022a91..2b8443e07 100644 --- a/bandit/plugins/injection_sql.py +++ b/bandit/plugins/injection_sql.py @@ -63,6 +63,7 @@ Flag when str.replace is used in the string construction """ # noqa: E501 + import ast import re diff --git a/bandit/plugins/injection_wildcard.py b/bandit/plugins/injection_wildcard.py index 46f6b5b6c..2546f804f 100644 --- a/bandit/plugins/injection_wildcard.py +++ b/bandit/plugins/injection_wildcard.py @@ -99,6 +99,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/jinja2_templates.py b/bandit/plugins/jinja2_templates.py index 3374205fe..4fc1fbacb 100644 --- a/bandit/plugins/jinja2_templates.py +++ b/bandit/plugins/jinja2_templates.py @@ -63,6 +63,7 @@ CWE information added """ + import ast import bandit diff --git a/bandit/plugins/logging_config_insecure_listen.py b/bandit/plugins/logging_config_insecure_listen.py index 96815f036..b0e723c2e 100644 --- a/bandit/plugins/logging_config_insecure_listen.py +++ b/bandit/plugins/logging_config_insecure_listen.py @@ -38,6 +38,7 @@ .. versionadded:: 1.7.5 """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/mako_templates.py b/bandit/plugins/mako_templates.py index 21e815105..75dfed625 100644 --- a/bandit/plugins/mako_templates.py +++ b/bandit/plugins/mako_templates.py @@ -42,6 +42,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/markupsafe_markup_xss.py b/bandit/plugins/markupsafe_markup_xss.py index 7eae90509..2a04998a0 100644 --- a/bandit/plugins/markupsafe_markup_xss.py +++ b/bandit/plugins/markupsafe_markup_xss.py @@ -68,6 +68,7 @@ .. versionadded:: 1.8.3 """ + import ast import bandit diff --git a/bandit/plugins/pytorch_load.py b/bandit/plugins/pytorch_load.py index 667cbb0d1..2f6028bcc 100644 --- a/bandit/plugins/pytorch_load.py +++ b/bandit/plugins/pytorch_load.py @@ -42,6 +42,7 @@ .. versionadded:: 1.7.10 """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/request_without_timeout.py b/bandit/plugins/request_without_timeout.py index c6439001b..a4ae89b37 100644 --- a/bandit/plugins/request_without_timeout.py +++ b/bandit/plugins/request_without_timeout.py @@ -47,6 +47,7 @@ Added check for httpx module """ # noqa: E501 + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/ssh_no_host_key_verification.py b/bandit/plugins/ssh_no_host_key_verification.py index 51be2eb4a..c7b8c5b65 100644 --- a/bandit/plugins/ssh_no_host_key_verification.py +++ b/bandit/plugins/ssh_no_host_key_verification.py @@ -35,6 +35,7 @@ CWE information added """ + import ast import bandit diff --git a/bandit/plugins/tarfile_unsafe_members.py b/bandit/plugins/tarfile_unsafe_members.py index 499a66789..4488fd956 100644 --- a/bandit/plugins/tarfile_unsafe_members.py +++ b/bandit/plugins/tarfile_unsafe_members.py @@ -46,6 +46,7 @@ Added check for filter parameter """ + import ast import bandit diff --git a/bandit/plugins/trojansource.py b/bandit/plugins/trojansource.py index ddf244839..c754e1222 100755 --- a/bandit/plugins/trojansource.py +++ b/bandit/plugins/trojansource.py @@ -30,13 +30,13 @@ .. versionadded:: 1.7.10 """ # noqa: E501 + from tokenize import detect_encoding import bandit from bandit.core import issue from bandit.core import test_properties as test - BIDI_CHARACTERS = ( "\u202a", "\u202b", diff --git a/bandit/plugins/try_except_continue.py b/bandit/plugins/try_except_continue.py index c2e3ad493..8a4de111e 100644 --- a/bandit/plugins/try_except_continue.py +++ b/bandit/plugins/try_except_continue.py @@ -74,6 +74,7 @@ class (or no type). To accommodate this, the test may be configured to ignore CWE information added """ + import ast import bandit diff --git a/bandit/plugins/try_except_pass.py b/bandit/plugins/try_except_pass.py index eda0ef800..c3ca33a16 100644 --- a/bandit/plugins/try_except_pass.py +++ b/bandit/plugins/try_except_pass.py @@ -72,6 +72,7 @@ class (or no type). To accommodate this, the test may be configured to ignore CWE information added """ + import ast import bandit diff --git a/bandit/plugins/weak_cryptographic_key.py b/bandit/plugins/weak_cryptographic_key.py index da73ced63..e51aee149 100644 --- a/bandit/plugins/weak_cryptographic_key.py +++ b/bandit/plugins/weak_cryptographic_key.py @@ -39,6 +39,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/bandit/plugins/yaml_load.py b/bandit/plugins/yaml_load.py index 2304c1d7d..fb81a9490 100644 --- a/bandit/plugins/yaml_load.py +++ b/bandit/plugins/yaml_load.py @@ -41,6 +41,7 @@ CWE information added """ + import bandit from bandit.core import issue from bandit.core import test_properties as test diff --git a/setup.py b/setup.py index 0f6e67b57..e7f717712 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,6 @@ import setuptools - data_files = [] man_path = "doc/build/man/bandit.1" if os.path.isfile(man_path): diff --git a/tests/functional/test_runtime.py b/tests/functional/test_runtime.py index a9eb21608..d3d2853be 100644 --- a/tests/functional/test_runtime.py +++ b/tests/functional/test_runtime.py @@ -26,7 +26,7 @@ def _test_example(self, cmdlist, targets): return self._test_runtime(cmdlist) def test_no_arguments(self): - (retcode, output) = self._test_runtime( + retcode, output = self._test_runtime( [ "bandit", ] @@ -36,7 +36,7 @@ def test_no_arguments(self): def test_piped_input(self): with open("examples/imports.py") as infile: - (retcode, output) = self._test_runtime(["bandit", "-"], infile) + retcode, output = self._test_runtime(["bandit", "-"], infile) self.assertEqual(1, retcode) self.assertIn("Total lines of code: 4", output) self.assertIn("Low: 2", output) @@ -47,14 +47,14 @@ def test_piped_input(self): self.assertIn(":4", output) def test_nonexistent_config(self): - (retcode, output) = self._test_runtime( + retcode, output = self._test_runtime( ["bandit", "-c", "nonexistent.yml", "xx.py"] ) self.assertEqual(2, retcode) self.assertIn("nonexistent.yml : Could not read config file.", output) def test_help_arg(self): - (retcode, output) = self._test_runtime(["bandit", "-h"]) + retcode, output = self._test_runtime(["bandit", "-h"]) self.assertEqual(0, retcode) self.assertIn( "Bandit - a Python source code security analyzer", output @@ -65,7 +65,7 @@ def test_help_arg(self): # test examples (use _test_example() to wrap in config location argument def test_example_nonexistent(self): - (retcode, output) = self._test_example( + retcode, output = self._test_example( [ "bandit", ], @@ -78,7 +78,7 @@ def test_example_nonexistent(self): self.assertIn("nonexistent.py (No such file or directory", output) def test_example_okay(self): - (retcode, output) = self._test_example( + retcode, output = self._test_example( [ "bandit", ], @@ -92,7 +92,7 @@ def test_example_okay(self): self.assertIn("No issues identified.", output) def test_example_nonsense(self): - (retcode, output) = self._test_example( + retcode, output = self._test_example( [ "bandit", ], @@ -105,7 +105,7 @@ def test_example_nonsense(self): self.assertIn("nonsense.py (syntax error while parsing AST", output) def test_example_nonsense2(self): - (retcode, output) = self._test_example( + retcode, output = self._test_example( [ "bandit", ], @@ -118,7 +118,7 @@ def test_example_nonsense2(self): self.assertIn("nonsense2.py (syntax error while parsing AST", output) def test_example_imports(self): - (retcode, output) = self._test_example( + retcode, output = self._test_example( [ "bandit", ], diff --git a/tests/unit/core/test_config.py b/tests/unit/core/test_config.py index 16aed0788..8f5628027 100644 --- a/tests/unit/core/test_config.py +++ b/tests/unit/core/test_config.py @@ -77,12 +77,10 @@ def setUp(self): self.example_key = uuid.uuid4().hex self.example_subkey = uuid.uuid4().hex self.example_subvalue = uuid.uuid4().hex - sample_yaml = textwrap.dedent( - f""" + sample_yaml = textwrap.dedent(f""" {self.example_key}: {self.example_subkey}: {self.example_subvalue} - """ - ) + """) f = self.useFixture(TempFile(sample_yaml)) @@ -118,8 +116,7 @@ def test_not_exist(self): class TestConfigCompat(testtools.TestCase): - sample = textwrap.dedent( - """ + sample = textwrap.dedent(""" profiles: test_1: include: @@ -163,8 +160,7 @@ class TestConfigCompat(testtools.TestCase): imports: [telnetlib] level: HIGH message: "{module} is considered insecure." - """ - ) + """) suffix = ".yaml" def setUp(self): @@ -280,8 +276,7 @@ def test_bad_yaml(self): class TestTomlConfig(TestConfigCompat): - sample = textwrap.dedent( - """ + sample = textwrap.dedent(""" [tool.bandit.profiles.test_1] include = [ "any_other_function_with_shell_equals_true", @@ -314,6 +309,5 @@ class TestTomlConfig(TestConfigCompat): imports = ["telnetlib"] level = "HIGH" message = "{module} is considered insecure." - """ - ) + """) suffix = ".toml" diff --git a/tests/unit/core/test_manager.py b/tests/unit/core/test_manager.py index 5d20c56f8..f3c4a178e 100644 --- a/tests/unit/core/test_manager.py +++ b/tests/unit/core/test_manager.py @@ -148,9 +148,7 @@ def test_populate_baseline_success(self): } ] } - """ % ( - "https://cwe.mitre.org/data/definitions/605.html" - ) + """ % ("https://cwe.mitre.org/data/definitions/605.html") issue_dictionary = { "code": "test code", "filename": "example_file.py", diff --git a/tests/unit/core/test_util.py b/tests/unit/core/test_util.py index 2747eef58..37d3e3589 100644 --- a/tests/unit/core/test_util.py +++ b/tests/unit/core/test_util.py @@ -229,7 +229,7 @@ def test_namespace_path_join(self): self.assertEqual("base1.base2.name", p) def test_namespace_path_split(self): - (head, tail) = b_utils.namespace_path_split("base1.base2.name") + head, tail = b_utils.namespace_path_split("base1.base2.name") self.assertEqual("base1.base2", head) self.assertEqual("name", tail) diff --git a/tests/unit/formatters/test_csv.py b/tests/unit/formatters/test_csv.py index 99f4c4b53..5f6314353 100644 --- a/tests/unit/formatters/test_csv.py +++ b/tests/unit/formatters/test_csv.py @@ -18,7 +18,7 @@ def setUp(self): super().setUp() conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.context = { "filename": self.tmp_fname, "lineno": 4, diff --git a/tests/unit/formatters/test_custom.py b/tests/unit/formatters/test_custom.py index 5481b71a8..527a2b098 100644 --- a/tests/unit/formatters/test_custom.py +++ b/tests/unit/formatters/test_custom.py @@ -16,7 +16,7 @@ def setUp(self): super().setUp() conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "custom") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.context = { "filename": self.tmp_fname, "lineno": 4, diff --git a/tests/unit/formatters/test_html.py b/tests/unit/formatters/test_html.py index 07e6bd0b4..09bcb146b 100644 --- a/tests/unit/formatters/test_html.py +++ b/tests/unit/formatters/test_html.py @@ -22,7 +22,7 @@ def setUp(self): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname diff --git a/tests/unit/formatters/test_json.py b/tests/unit/formatters/test_json.py index 821e8e593..f0c3aaf09 100644 --- a/tests/unit/formatters/test_json.py +++ b/tests/unit/formatters/test_json.py @@ -22,7 +22,7 @@ def setUp(self): super().setUp() conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.context = { "filename": self.tmp_fname, "lineno": 4, diff --git a/tests/unit/formatters/test_sarif.py b/tests/unit/formatters/test_sarif.py index a5306fa81..2475911bf 100644 --- a/tests/unit/formatters/test_sarif.py +++ b/tests/unit/formatters/test_sarif.py @@ -20,7 +20,7 @@ def setUp(self): super().setUp() conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.context = { "filename": self.tmp_fname, "lineno": 4, diff --git a/tests/unit/formatters/test_screen.py b/tests/unit/formatters/test_screen.py index b560247cd..cb7205ed2 100644 --- a/tests/unit/formatters/test_screen.py +++ b/tests/unit/formatters/test_screen.py @@ -84,7 +84,7 @@ def test_no_issues(self, get_issue_list): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname get_issue_list.return_value = collections.OrderedDict() @@ -103,7 +103,7 @@ def test_report_nobaseline(self, get_issue_list): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname self.manager.verbose = True @@ -196,7 +196,7 @@ def test_report_baseline(self, get_issue_list): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname issue_a = _get_issue_instance() diff --git a/tests/unit/formatters/test_text.py b/tests/unit/formatters/test_text.py index a868c3468..6b02a06ea 100644 --- a/tests/unit/formatters/test_text.py +++ b/tests/unit/formatters/test_text.py @@ -70,7 +70,7 @@ def test_no_issues(self, get_issue_list): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname get_issue_list.return_value = collections.OrderedDict() @@ -88,7 +88,7 @@ def test_report_nobaseline(self, get_issue_list): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname self.manager.verbose = True @@ -171,7 +171,7 @@ def test_report_baseline(self, get_issue_list): conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.manager.out_file = self.tmp_fname issue_a = _get_issue_instance() diff --git a/tests/unit/formatters/test_xml.py b/tests/unit/formatters/test_xml.py index ac503972f..95c38905d 100644 --- a/tests/unit/formatters/test_xml.py +++ b/tests/unit/formatters/test_xml.py @@ -19,7 +19,7 @@ def setUp(self): super().setUp() conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.context = { "filename": self.tmp_fname, "lineno": 4, diff --git a/tests/unit/formatters/test_yaml.py b/tests/unit/formatters/test_yaml.py index 089e1ac1c..fa6d6735a 100644 --- a/tests/unit/formatters/test_yaml.py +++ b/tests/unit/formatters/test_yaml.py @@ -22,7 +22,7 @@ def setUp(self): super().setUp() conf = config.BanditConfig() self.manager = manager.BanditManager(conf, "file") - (tmp_fd, self.tmp_fname) = tempfile.mkstemp() + tmp_fd, self.tmp_fname = tempfile.mkstemp() self.context = { "filename": self.tmp_fname, "lineno": 4,