Skip to content

Commit edadccd

Browse files
committedMar 31, 2021
audit + string joining
1 parent e9a2a10 commit edadccd

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed
 

‎src/flake8/main/application.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@ def report_benchmarks(self):
275275
add_statistic = statistics.append
276276
for statistic in defaults.STATISTIC_NAMES + ("files",):
277277
value = self.file_checker_manager.statistics[statistic]
278-
total_description = "total " + statistic + " processed"
278+
total_description = f"total {statistic} processed"
279279
add_statistic((total_description, value))
280-
per_second_description = statistic + " processed per second"
280+
per_second_description = f"{statistic} processed per second"
281281
add_statistic((per_second_description, int(value / time_elapsed)))
282282

283283
self.formatter.show_benchmarks(statistics)

‎src/flake8/options/config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def __init__(
5151
self.user_config_file = self._user_config_file(program_name)
5252

5353
# List of filenames to find in the local/project directory
54-
self.project_filenames = ("setup.cfg", "tox.ini", "." + program_name)
54+
self.project_filenames = ("setup.cfg", "tox.ini", f".{program_name}")
5555

5656
self.local_directory = os.path.abspath(os.curdir)
5757

5858
@staticmethod
5959
def _user_config_file(program_name: str) -> str:
6060
if utils.is_windows():
6161
home_dir = os.path.expanduser("~")
62-
config_file_basename = "." + program_name
62+
config_file_basename = f".{program_name}"
6363
else:
6464
home_dir = os.environ.get(
6565
"XDG_CONFIG_HOME", os.path.expanduser("~/.config")

‎src/flake8/plugins/pyflakes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def parse_options(cls, options):
145145
if included_file == "":
146146
continue
147147
if not included_file.startswith((os.sep, "./", "~/")):
148-
included_files.append("./" + included_file)
148+
included_files.append(f"./{included_file}")
149149
else:
150150
included_files.append(included_file)
151151
cls.include_in_doctest = utils.normalize_paths(included_files)
@@ -155,7 +155,7 @@ def parse_options(cls, options):
155155
if excluded_file == "":
156156
continue
157157
if not excluded_file.startswith((os.sep, "./", "~/")):
158-
excluded_files.append("./" + excluded_file)
158+
excluded_files.append(f"./{excluded_file}")
159159
else:
160160
excluded_files.append(excluded_file)
161161
cls.exclude_from_doctest = utils.normalize_paths(excluded_files)

‎src/flake8/processor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def build_logical_line_tokens(self) -> _Logical:
218218
if previous_text == "," or (
219219
previous_text not in "{[(" and text not in "}])"
220220
):
221-
text = " " + text
221+
text = f" {text}"
222222
elif previous_column != start_column:
223223
text = line[previous_column:start_column] + text
224224
logical.append(text)

‎src/flake8/utils.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import platform
1010
import re
1111
import sys
12+
import textwrap
1213
import tokenize
1314
from typing import Callable
1415
from typing import Dict
@@ -122,13 +123,11 @@ def _reset() -> None:
122123
State.codes = []
123124

124125
def _unexpected_token() -> exceptions.ExecutionError:
125-
def _indent(s: str) -> str:
126-
return " " + s.strip().replace("\n", "\n ")
127-
128126
return exceptions.ExecutionError(
129127
f"Expected `per-file-ignores` to be a mapping from file exclude "
130128
f"patterns to ignore codes.\n\n"
131-
f"Configured `per-file-ignores` setting:\n\n{_indent(value)}"
129+
f"Configured `per-file-ignores` setting:\n\n"
130+
f"{textwrap.indent(value.strip(), ' ')}"
132131
)
133132

134133
for token in _tokenize_files_to_codes_mapping(value):

‎tests/unit/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_normalize_path(value, expected):
134134
(["flake8", "pep8", "pyflakes", "mccabe"],
135135
["flake8", "pep8", "pyflakes", "mccabe"]),
136136
(["../flake8", "../pep8", "../pyflakes", "../mccabe"],
137-
[os.path.abspath("../" + p) for p in RELATIVE_PATHS]),
137+
[os.path.abspath(f"../{p}") for p in RELATIVE_PATHS]),
138138
])
139139
def test_normalize_paths(value, expected):
140140
"""Verify we normalizes a sequence of paths provided to the tool."""

0 commit comments

Comments
 (0)
Please sign in to comment.