Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1099a4

Browse files
author
Lorenzo De Bernardini
authored
Merge pull request #810 from Yelp/lorenzodb1-add-support-for-py3.12
Add support for Python 3.12
2 parents 799a791 + adb41ed commit c1099a4

10 files changed

Lines changed: 39 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ubuntu-latest, macos-latest, windows-latest]
20-
python: ['3.8', '3.9', '3.10', '3.11']
20+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
2121
steps:
2222
- uses: actions/checkout@v2
2323
- uses: actions/setup-python@v2

.github/workflows/pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest]
18-
python: ['3.8', '3.9', '3.10', '3.11']
18+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
1919
steps:
2020
- uses: actions/checkout@v2
2121
- uses: actions/setup-python@v2

detect_secrets/core/scan.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,19 @@ def _is_filtered_out(required_filter_parameters: Iterable[str], **kwargs: Any) -
391391
try:
392392
if call_function_with_arguments(filter_fn, **kwargs):
393393
if 'secret' in kwargs:
394-
debug_msg = f'Skipping "{kwargs["secret"]}" due to `{filter_fn.path}`.'
394+
debug_msg = f'Skipping "{0}" due to `{1}`.'.format(
395+
kwargs['secret'],
396+
filter_fn.path,
397+
)
395398
elif list(kwargs.keys()) == ['filename']:
396399
# We want to make sure this is only run if we're skipping files (as compared
397400
# to other filters that may include `filename` as a parameter).
398-
debug_msg = f'Skipping "{kwargs["filename"]}" due to `{filter_fn.path}`'
401+
debug_msg = 'Skipping "{0}" due to `{1}`'.format(
402+
kwargs['filename'],
403+
filter_fn.path,
404+
)
399405
else:
400-
debug_msg = f'Skipping secret due to `{filter_fn.path}`.'
406+
debug_msg = 'Skipping secret due to `{0}`.'.format(filter_fn.path)
401407

402408
log.info(debug_msg)
403409
return True

detect_secrets/pre_commit_hook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ def pretty_print_diagnostics(secrets: SecretsCollection, width: int = 80) -> Non
147147
)
148148
for suggestion in [
149149
'For information about putting your secrets in a safer place, '
150-
f'please ask {os.environ.get("DETECT_SECRETS_SECURITY_TEAM", "in #security")}',
150+
'please ask {0}'.format(os.environ.get('DETECT_SECRETS_SECURITY_TEAM', 'in #security')),
151151

152152
'Mark false positives with an inline '
153-
f'`{color.colorize("pragma: allowlist secret", color.AnsiColor.BOLD)}` comment',
153+
'`{0}` comment'.format(color.colorize('pragma: allowlist secret', color.AnsiColor.BOLD)),
154154
]:
155155
print(wrapper.fill(suggestion))
156156

tests/audit/report_test.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,24 @@ def create_file_with_content(content):
206206
@pytest.fixture
207207
def baseline_file():
208208
# Create our own SecretsCollection manually, so that we have fine-tuned control.
209-
first_content = textwrap.dedent(f"""
209+
first_content = textwrap.dedent(
210+
f"""
210211
url = {url_format.format(first_secret)}
211212
example = {url_format.format(random_secret)}
212213
link = {url_format.format(first_secret)}
213-
""")[1:]
214-
second_content = textwrap.dedent(f"""
214+
""",
215+
)[1:]
216+
second_content = textwrap.dedent(
217+
f"""
215218
url = {url_format.format(second_secret)}
216219
example = {url_format.format(random_secret)}
217-
""")[1:]
218-
third_content = textwrap.dedent(f"""
220+
""",
221+
)[1:]
222+
third_content = textwrap.dedent(
223+
f"""
219224
aws_access_key = {aws_secret}
220-
""")[1:]
225+
""",
226+
)[1:]
221227

222228
with create_file_with_content(first_content) as first_file, \
223229
create_file_with_content(second_content) as second_file, \

tests/core/upgrades/upgrade_to_v1_0_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_custom_plugins_does_not_pollute_settings():
2626
assert new_baseline['plugins_used'] == [
2727
{
2828
'name': 'HippoDetector',
29-
'path': f'file://{os.path.abspath("testing/plugins.py")}',
29+
'path': 'file://{0}'.format(os.path.abspath('testing/plugins.py')),
3030
},
3131
]
3232
with pytest.raises(TypeError):

tests/core/usage/plugins_usage_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_success(parser):
158158

159159
parser.parse_args(['--baseline', f.name])
160160
assert get_settings().plugins['HippoDetector'] == {
161-
'path': f'file://{os.path.abspath("testing/plugins.py")}',
161+
'path': 'file://{0}'.format(os.path.abspath('testing/plugins.py')),
162162
}
163163
assert plugins.initialize.from_plugin_classname('HippoDetector')
164164

tests/plugins/aws_key_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def counter(*args, **kwargs):
118118
self.example_key,
119119
get_code_snippet(
120120
[
121-
f'false_secret = {"TEST" * 10}',
122-
f'real_secret = {EXAMPLE_SECRET}',
121+
'false_secret = {0}'.format('TEST' * 10),
122+
'real_secret = {0}'.format(EXAMPLE_SECRET),
123123
],
124124
1,
125125
),

tests/transformers/yaml_transformer_test.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ def test_multiline_block_scalar_folded_style(block_chomping):
5353
# However, "folded" style may be used to keep a certain line limit with very long secrets,
5454
# so we should probably handle that.
5555
file = mock_file_object(
56-
textwrap.dedent(f"""
56+
textwrap.dedent(
57+
f"""
5758
multiline: |{block_chomping} # example
5859
this is
5960
a basic multiline string
60-
""")[1:-1],
61+
""",
62+
)[1:-1],
6163
)
6264

6365
assert YAMLTransformer().parse_file(file) == [
@@ -195,12 +197,14 @@ def test_basic():
195197
def test_multi_line(block_scalar_style, block_chomping):
196198
# NOTE: Referenced https://yaml-multiline.info/ for the many ways to do multi line strings
197199
file = mock_file_object(
198-
textwrap.dedent(f"""
200+
textwrap.dedent(
201+
f"""
199202
key: {block_scalar_style}{block_chomping} # comment
200203
multi
201-
#line
204+
# line
202205
string
203-
""")[1:-1],
206+
""",
207+
)[1:-1],
204208
)
205209

206210
assert [item.line for item in YAMLFileParser(file)] == [

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
project = detect_secrets
33
# These should match the ci python env list
4-
envlist = py{38,39,310,311},mypy
4+
envlist = py{38,39,310,311,312},mypy
55
skip_missing_interpreters = true
66

77
[testenv]

0 commit comments

Comments
 (0)