summaryrefslogtreecommitdiff
path: root/src/flake8
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-03-29 19:54:47 -0700
committerAnthony Sottile <asottile@umich.edu>2021-03-30 17:37:13 -0700
commitc4c4351699442195df64d3540d58c9fe221a48ae (patch)
treee6ef4445310d4d1111d76146332c56ece8715781 /src/flake8
parentcb36e206a5ed5610a2f94f9893bbfd75036dc0ad (diff)
downloadflake8-c4c4351699442195df64d3540d58c9fe221a48ae.tar.gz
audit .format(...) calls
Diffstat (limited to 'src/flake8')
-rw-r--r--src/flake8/checker.py8
-rw-r--r--src/flake8/exceptions.py4
-rw-r--r--src/flake8/formatting/base.py8
-rw-r--r--src/flake8/options/manager.py2
-rw-r--r--src/flake8/utils.py8
5 files changed, 9 insertions, 21 deletions
diff --git a/src/flake8/checker.py b/src/flake8/checker.py
index ceff965..421d461 100644
--- a/src/flake8/checker.py
+++ b/src/flake8/checker.py
@@ -380,8 +380,7 @@ class FileChecker:
# NOTE(sigmavirus24): Historically, pep8 has always reported this
# as an E902. We probably *want* a better error code for this
# going forward.
- message = "{}: {}".format(type(e).__name__, e)
- self.report("E902", 0, 0, message)
+ self.report("E902", 0, 0, f"{type(e).__name__}: {e}")
return None
def report(
@@ -473,10 +472,7 @@ class FileChecker:
except (ValueError, SyntaxError, TypeError) as e:
row, column = self._extract_syntax_information(e)
self.report(
- "E999",
- row,
- column,
- "{}: {}".format(type(e).__name__, e.args[0]),
+ "E999", row, column, f"{type(e).__name__}: {e.args[0]}"
)
return
diff --git a/src/flake8/exceptions.py b/src/flake8/exceptions.py
index caa4677..a8d2f6e 100644
--- a/src/flake8/exceptions.py
+++ b/src/flake8/exceptions.py
@@ -39,8 +39,8 @@ class InvalidSyntax(Flake8Exception):
def __init__(self, exception: Exception) -> None:
"""Initialize our InvalidSyntax exception."""
self.original_exception = exception
- self.error_message = "{}: {}".format(
- exception.__class__.__name__, exception.args[0]
+ self.error_message = (
+ f"{type(exception).__name__}: {exception.args[0]}"
)
self.error_code = "E902"
self.line_number = 1
diff --git a/src/flake8/formatting/base.py b/src/flake8/formatting/base.py
index 81897b2..e362e65 100644
--- a/src/flake8/formatting/base.py
+++ b/src/flake8/formatting/base.py
@@ -121,13 +121,7 @@ class BaseFormatter:
statistic = next(stats_for_error_code)
count = statistic.count
count += sum(stat.count for stat in stats_for_error_code)
- self._write(
- "{count:<5} {error_code} {message}".format(
- count=count,
- error_code=error_code,
- message=statistic.message,
- )
- )
+ self._write(f"{count:<5} {error_code} {statistic.message}")
def show_benchmarks(self, benchmarks: List[Tuple[str, float]]) -> None:
"""Format and print the benchmarks."""
diff --git a/src/flake8/options/manager.py b/src/flake8/options/manager.py
index 5019499..28cee4d 100644
--- a/src/flake8/options/manager.py
+++ b/src/flake8/options/manager.py
@@ -295,7 +295,7 @@ class Option:
parts.append(arg)
for k, v in self.filtered_option_kwargs.items():
parts.append(f"{k}={v!r}")
- return "Option({})".format(", ".join(parts))
+ return f"Option({', '.join(parts)})"
def normalize(self, value: Any, *normalize_args: str) -> Any:
"""Normalize the value based on the option configuration."""
diff --git a/src/flake8/utils.py b/src/flake8/utils.py
index 530801d..ee81de7 100644
--- a/src/flake8/utils.py
+++ b/src/flake8/utils.py
@@ -126,11 +126,9 @@ def parse_files_to_codes_mapping( # noqa: C901
return " " + s.strip().replace("\n", "\n ")
return exceptions.ExecutionError(
- "Expected `per-file-ignores` to be a mapping from file exclude "
- "patterns to ignore codes.\n\n"
- "Configured `per-file-ignores` setting:\n\n{}".format(
- _indent(value)
- )
+ f"Expected `per-file-ignores` to be a mapping from file exclude "
+ f"patterns to ignore codes.\n\n"
+ f"Configured `per-file-ignores` setting:\n\n{_indent(value)}"
)
for token in _tokenize_files_to_codes_mapping(value):