diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfe15f4b1..d7c3ddb12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python: ['3.8', '3.9', '3.10', '3.11'] + python: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 13b128ace..ba324b00d 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - python: ['3.8', '3.9', '3.10', '3.11'] + python: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/detect_secrets/core/scan.py b/detect_secrets/core/scan.py index f84d53c3c..3e9496828 100644 --- a/detect_secrets/core/scan.py +++ b/detect_secrets/core/scan.py @@ -387,13 +387,19 @@ def _is_filtered_out(required_filter_parameters: Iterable[str], **kwargs: Any) - try: if call_function_with_arguments(filter_fn, **kwargs): if 'secret' in kwargs: - debug_msg = f'Skipping "{kwargs["secret"]}" due to `{filter_fn.path}`.' + debug_msg = f'Skipping "{0}" due to `{1}`.'.format( + kwargs['secret'], + filter_fn.path, + ) elif list(kwargs.keys()) == ['filename']: # We want to make sure this is only run if we're skipping files (as compared # to other filters that may include `filename` as a parameter). - debug_msg = f'Skipping "{kwargs["filename"]}" due to `{filter_fn.path}`' + debug_msg = 'Skipping "{0}" due to `{1}`'.format( + kwargs['filename'], + filter_fn.path, + ) else: - debug_msg = f'Skipping secret due to `{filter_fn.path}`.' + debug_msg = 'Skipping secret due to `{0}`.'.format(filter_fn.path) log.info(debug_msg) return True diff --git a/detect_secrets/pre_commit_hook.py b/detect_secrets/pre_commit_hook.py index fb75832e3..92757496c 100644 --- a/detect_secrets/pre_commit_hook.py +++ b/detect_secrets/pre_commit_hook.py @@ -147,10 +147,10 @@ def pretty_print_diagnostics(secrets: SecretsCollection, width: int = 80) -> Non ) for suggestion in [ 'For information about putting your secrets in a safer place, ' - f'please ask {os.environ.get("DETECT_SECRETS_SECURITY_TEAM", "in #security")}', + 'please ask {0}'.format(os.environ.get('DETECT_SECRETS_SECURITY_TEAM', 'in #security')), 'Mark false positives with an inline ' - f'`{color.colorize("pragma: allowlist secret", color.AnsiColor.BOLD)}` comment', + '`{0}` comment'.format(color.colorize('pragma: allowlist secret', color.AnsiColor.BOLD)), ]: print(wrapper.fill(suggestion)) diff --git a/tests/audit/report_test.py b/tests/audit/report_test.py index a83e3585d..6414ab9d6 100644 --- a/tests/audit/report_test.py +++ b/tests/audit/report_test.py @@ -206,18 +206,24 @@ def create_file_with_content(content): @pytest.fixture def baseline_file(): # Create our own SecretsCollection manually, so that we have fine-tuned control. - first_content = textwrap.dedent(f""" + first_content = textwrap.dedent( + f""" url = {url_format.format(first_secret)} example = {url_format.format(random_secret)} link = {url_format.format(first_secret)} - """)[1:] - second_content = textwrap.dedent(f""" + """, + )[1:] + second_content = textwrap.dedent( + f""" url = {url_format.format(second_secret)} example = {url_format.format(random_secret)} - """)[1:] - third_content = textwrap.dedent(f""" + """, + )[1:] + third_content = textwrap.dedent( + f""" aws_access_key = {aws_secret} - """)[1:] + """, + )[1:] with create_file_with_content(first_content) as first_file, \ create_file_with_content(second_content) as second_file, \ diff --git a/tests/core/upgrades/upgrade_to_v1_0_test.py b/tests/core/upgrades/upgrade_to_v1_0_test.py index c93ab17aa..1c54bdf44 100644 --- a/tests/core/upgrades/upgrade_to_v1_0_test.py +++ b/tests/core/upgrades/upgrade_to_v1_0_test.py @@ -26,7 +26,7 @@ def test_custom_plugins_does_not_pollute_settings(): assert new_baseline['plugins_used'] == [ { 'name': 'HippoDetector', - 'path': f'file://{os.path.abspath("testing/plugins.py")}', + 'path': 'file://{0}'.format(os.path.abspath('testing/plugins.py')), }, ] with pytest.raises(TypeError): diff --git a/tests/core/usage/plugins_usage_test.py b/tests/core/usage/plugins_usage_test.py index f7bc21b81..73b5a25ac 100644 --- a/tests/core/usage/plugins_usage_test.py +++ b/tests/core/usage/plugins_usage_test.py @@ -158,7 +158,7 @@ def test_success(parser): parser.parse_args(['--baseline', f.name]) assert get_settings().plugins['HippoDetector'] == { - 'path': f'file://{os.path.abspath("testing/plugins.py")}', + 'path': 'file://{0}'.format(os.path.abspath('testing/plugins.py')), } assert plugins.initialize.from_plugin_classname('HippoDetector') diff --git a/tests/plugins/aws_key_test.py b/tests/plugins/aws_key_test.py index 9139c9dd6..166269aab 100644 --- a/tests/plugins/aws_key_test.py +++ b/tests/plugins/aws_key_test.py @@ -118,8 +118,8 @@ def counter(*args, **kwargs): self.example_key, get_code_snippet( [ - f'false_secret = {"TEST" * 10}', - f'real_secret = {EXAMPLE_SECRET}', + 'false_secret = {0}'.format('TEST' * 10), + 'real_secret = {0}'.format(EXAMPLE_SECRET), ], 1, ), diff --git a/tests/transformers/yaml_transformer_test.py b/tests/transformers/yaml_transformer_test.py index 5c0f467f9..3ecbd9d42 100644 --- a/tests/transformers/yaml_transformer_test.py +++ b/tests/transformers/yaml_transformer_test.py @@ -53,11 +53,13 @@ def test_multiline_block_scalar_folded_style(block_chomping): # However, "folded" style may be used to keep a certain line limit with very long secrets, # so we should probably handle that. file = mock_file_object( - textwrap.dedent(f""" + textwrap.dedent( + f""" multiline: |{block_chomping} # example this is a basic multiline string - """)[1:-1], + """, + )[1:-1], ) assert YAMLTransformer().parse_file(file) == [ @@ -195,12 +197,14 @@ def test_basic(): def test_multi_line(block_scalar_style, block_chomping): # NOTE: Referenced https://yaml-multiline.info/ for the many ways to do multi line strings file = mock_file_object( - textwrap.dedent(f""" + textwrap.dedent( + f""" key: {block_scalar_style}{block_chomping} # comment multi - #line + # line string - """)[1:-1], + """, + )[1:-1], ) assert [item.line for item in YAMLFileParser(file)] == [ diff --git a/tox.ini b/tox.ini index 01f5d4d07..bb7e89591 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] project = detect_secrets # These should match the ci python env list -envlist = py{38,39,310,311},mypy +envlist = py{38,39,310,311,312},mypy skip_missing_interpreters = true [testenv]