Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert formatted string to f-string #235

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ci

on:
push:
branches: [ main ]
branches: [ main, v3.x ]
pull_request:
branches: [ main ]
branches: [ main, v3.x ]

jobs:
unit-test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: "CodeQL"

on:
push:
branches: [main, v1.x]
branches: [main, v1.x, v3.x]
pull_request:
# The branches below must be a subset of the branches above
branches: [main, v1.x]
branches: [main, v1.x, v3.x]
schedule:
- cron: '0 6 * * 3'

Expand Down
352 changes: 192 additions & 160 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ maintainers = ["GoDaddy <oss@godaddy.com>"]
name = "tartufo"
readme = "README.md"
repository = "https://github.com/godaddy/tartufo/"
version = "2.9.0"
version = "3.0.0-dev.0"

[tool.poetry.scripts]
tartufo = "tartufo.cli:main"
Expand Down Expand Up @@ -180,7 +180,7 @@ ignore_missing_imports = true
# R0914: Too many local variables
# W0511: FIXME
# E1136: Unsubscriptable object (Disabled due to Python 3.9 compatibility bug in pylint)
disable = "C0111,C0301,C0330,R0201,R0801,R0903,R0912,R0914,W0511,E1136"
disable = "C0111,C0301,C0330,R0201,R0801,R0903,R0912,R0914,W0511,E1136,W1514"

[tool.pylint.BASIC]
module-rgx = "(([a-z_][a-z0-9_]*)|([a-z][a-zA-Z0-9]+))$"
Expand Down
8 changes: 2 additions & 6 deletions tartufo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ def configure_regexes(
loaded = load_rules_from_file(rules_file)
dupes = set(loaded.keys()).intersection(rules.keys())
if dupes:
raise ValueError(
"Rule(s) were defined multiple times: {}".format(dupes)
)
raise ValueError(f"Rule(s) were defined multiple times: {dupes}")
rules.update(loaded)
finally:
if cloned_repo:
Expand All @@ -212,9 +210,7 @@ def load_rules_from_file(rules_file: TextIO) -> Dict[str, Rule]:
try:
new_rules = json.load(rules_file)
except json.JSONDecodeError as exc:
raise ValueError(
"Error loading rules from file: {}".format(rules_file.name)
) from exc
raise ValueError(f"Error loading rules from file: {rules_file.name}") from exc
for rule_name, rule_definition in new_rules.items():
try:
path_pattern = rule_definition.get("path_pattern", None)
Expand Down
10 changes: 5 additions & 5 deletions tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ def __str__(self) -> str:
self.matched_string, util.style_warning(self.matched_string)
)
output.append(self.OUTPUT_SEPARATOR)
output.append(util.style_ok("Reason: {}".format(self.issue_type.value))) # type: ignore
output.append(util.style_ok(f"Reason: {self.issue_type.value}")) # type: ignore
if self.issue_detail:
output.append(util.style_ok("Detail: {}".format(self.issue_detail)))
output.append(util.style_ok("Filepath: {}".format(self.chunk.file_path)))
output.append(util.style_ok("Signature: {}".format(self.signature)))
output.append(util.style_ok(f"Detail: {self.issue_detail}"))
output.append(util.style_ok(f"Filepath: {self.chunk.file_path}"))
output.append(util.style_ok(f"Signature: {self.signature}"))
output += [
util.style_ok("{}: {}".format(k.replace("_", " ").capitalize(), v))
util.style_ok(f"{k.replace('_', ' ').capitalize()}: {v}")
for k, v in self.chunk.metadata.items()
]

Expand Down
2 changes: 1 addition & 1 deletion tartufo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def generate_signature(snippet: str, filename: str) -> str:
:param snippet: A string which was found as a potential issue during a scan
:param filename: The file where the issue was found
"""
return blake2s("{}$${}".format(snippet, filename).encode("utf-8")).hexdigest()
return blake2s(f"{snippet}$${filename}".encode("utf-8")).hexdigest()


def extract_commit_metadata(
Expand Down
9 changes: 3 additions & 6 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ def test_configure_regexes_rules_files_without_defaults(self):
self.assertEqual(
expected_regexes,
actual_regexes,
"The regexes dictionary should match the test rules "
"(expected: {}, actual: {})".format(expected_regexes, actual_regexes),
f"The regexes dictionary should match the test rules (expected: {expected_regexes}, actual: {actual_regexes})",
)

def test_configure_regexes_rules_files_with_defaults(self):
Expand Down Expand Up @@ -69,8 +68,7 @@ def test_configure_regexes_rules_files_with_defaults(self):
self.assertEqual(
expected_regexes,
actual_regexes,
"The regexes dictionary should match the test rules "
"(expected: {}, actual: {})".format(expected_regexes, actual_regexes),
f"The regexes dictionary should match the test rules (expected: {expected_regexes}, actual: {actual_regexes})",
)

def test_configure_regexes_returns_just_default_regexes_by_default(self):
Expand Down Expand Up @@ -155,8 +153,7 @@ def test_configure_regexes_includes_rules_from_rules_repo(self):
self.assertEqual(
expected_regexes,
actual_regexes,
"The regexes dictionary should match the test rules "
"(expected: {}, actual: {})".format(expected_regexes, actual_regexes),
f"The regexes dictionary should match the test rules (expected: {expected_regexes}, actual: {actual_regexes})",
)


Expand Down