diff options
| author | Anthony Sottile <asottile@umich.edu> | 2021-03-29 20:07:13 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2021-03-30 17:37:13 -0700 |
| commit | edadccd8dcf5fc1de86116adb5f9f13ed1b68637 (patch) | |
| tree | 382ad5e83f6512ff157553c6a8c16b63569cec70 /src | |
| parent | e9a2a1018349f3eda9811bcadb63d4e2af05fd2f (diff) | |
| download | flake8-edadccd8dcf5fc1de86116adb5f9f13ed1b68637.tar.gz | |
audit + string joining
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/main/application.py | 4 | ||||
| -rw-r--r-- | src/flake8/options/config.py | 4 | ||||
| -rw-r--r-- | src/flake8/plugins/pyflakes.py | 4 | ||||
| -rw-r--r-- | src/flake8/processor.py | 2 | ||||
| -rw-r--r-- | src/flake8/utils.py | 7 |
5 files changed, 10 insertions, 11 deletions
diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py index e3be8c4..6e99ec2 100644 --- a/src/flake8/main/application.py +++ b/src/flake8/main/application.py @@ -275,9 +275,9 @@ class Application: add_statistic = statistics.append for statistic in defaults.STATISTIC_NAMES + ("files",): value = self.file_checker_manager.statistics[statistic] - total_description = "total " + statistic + " processed" + total_description = f"total {statistic} processed" add_statistic((total_description, value)) - per_second_description = statistic + " processed per second" + per_second_description = f"{statistic} processed per second" add_statistic((per_second_description, int(value / time_elapsed))) self.formatter.show_benchmarks(statistics) diff --git a/src/flake8/options/config.py b/src/flake8/options/config.py index 8fa5fb0..0a2ee63 100644 --- a/src/flake8/options/config.py +++ b/src/flake8/options/config.py @@ -51,7 +51,7 @@ class ConfigFileFinder: self.user_config_file = self._user_config_file(program_name) # List of filenames to find in the local/project directory - self.project_filenames = ("setup.cfg", "tox.ini", "." + program_name) + self.project_filenames = ("setup.cfg", "tox.ini", f".{program_name}") self.local_directory = os.path.abspath(os.curdir) @@ -59,7 +59,7 @@ class ConfigFileFinder: def _user_config_file(program_name: str) -> str: if utils.is_windows(): home_dir = os.path.expanduser("~") - config_file_basename = "." + program_name + config_file_basename = f".{program_name}" else: home_dir = os.environ.get( "XDG_CONFIG_HOME", os.path.expanduser("~/.config") diff --git a/src/flake8/plugins/pyflakes.py b/src/flake8/plugins/pyflakes.py index 8c68a01..4d1d7b8 100644 --- a/src/flake8/plugins/pyflakes.py +++ b/src/flake8/plugins/pyflakes.py @@ -145,7 +145,7 @@ class FlakesChecker(pyflakes.checker.Checker): if included_file == "": continue if not included_file.startswith((os.sep, "./", "~/")): - included_files.append("./" + included_file) + included_files.append(f"./{included_file}") else: included_files.append(included_file) cls.include_in_doctest = utils.normalize_paths(included_files) @@ -155,7 +155,7 @@ class FlakesChecker(pyflakes.checker.Checker): if excluded_file == "": continue if not excluded_file.startswith((os.sep, "./", "~/")): - excluded_files.append("./" + excluded_file) + excluded_files.append(f"./{excluded_file}") else: excluded_files.append(excluded_file) cls.exclude_from_doctest = utils.normalize_paths(excluded_files) diff --git a/src/flake8/processor.py b/src/flake8/processor.py index 73dd12b..7c4672a 100644 --- a/src/flake8/processor.py +++ b/src/flake8/processor.py @@ -218,7 +218,7 @@ class FileProcessor: if previous_text == "," or ( previous_text not in "{[(" and text not in "}])" ): - text = " " + text + text = f" {text}" elif previous_column != start_column: text = line[previous_column:start_column] + text logical.append(text) diff --git a/src/flake8/utils.py b/src/flake8/utils.py index ee81de7..fe5d907 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -9,6 +9,7 @@ import os import platform import re import sys +import textwrap import tokenize from typing import Callable from typing import Dict @@ -122,13 +123,11 @@ def parse_files_to_codes_mapping( # noqa: C901 State.codes = [] def _unexpected_token() -> exceptions.ExecutionError: - def _indent(s: str) -> str: - return " " + s.strip().replace("\n", "\n ") - return exceptions.ExecutionError( 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)}" + f"Configured `per-file-ignores` setting:\n\n" + f"{textwrap.indent(value.strip(), ' ')}" ) for token in _tokenize_files_to_codes_mapping(value): |
