From 411334901eb8b0f9cf0a035af9946624f4f482b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 17:43:18 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/tox/config/loader/ini/replace.py | 3 +-- src/tox/config/loader/section.py | 2 +- src/tox/config/of_type.py | 2 +- src/tox/config/sets.py | 2 +- src/tox/plugin/inline.py | 3 +-- src/tox/run.py | 3 +-- src/tox/session/env_select.py | 2 +- src/tox/tox_env/python/pip/req/file.py | 6 ++---- src/tox/tox_env/python/pip/req/util.py | 3 +-- src/tox/tox_env/python/pip/req_file.py | 3 +-- 10 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/tox/config/loader/ini/replace.py b/src/tox/config/loader/ini/replace.py index cd7ad43b3..9d9373989 100644 --- a/src/tox/config/loader/ini/replace.py +++ b/src/tox/config/loader/ini/replace.py @@ -259,8 +259,7 @@ def replace_reference( # noqa: PLR0912, C901 exception = exc else: as_str, _ = stringify(value) - as_str = as_str.replace("#", r"\#") # escape comment characters as these will be stripped - return as_str + return as_str.replace("#", r"\#") # escape comment characters as these will be stripped except Exception as exc: # noqa: BLE001 exception = exc if exception is not None: diff --git a/src/tox/config/loader/section.py b/src/tox/config/loader/section.py index bfbf3e4b7..d31665168 100644 --- a/src/tox/config/loader/section.py +++ b/src/tox/config/loader/section.py @@ -52,7 +52,7 @@ def __repr__(self) -> str: def __eq__(self, other: Any) -> bool: return isinstance(other, self.__class__) and (self._prefix, self._name) == ( - other._prefix, # noqa: SLF001 + other._prefix, other.name, ) diff --git a/src/tox/config/of_type.py b/src/tox/config/of_type.py index d3a951b7c..6c01a1231 100644 --- a/src/tox/config/of_type.py +++ b/src/tox/config/of_type.py @@ -71,7 +71,7 @@ def __init__( # noqa: PLR0913 of_type: type[T], default: Callable[[Config, str | None], T] | T, post_process: Callable[[T], T] | None = None, - factory: Factory[T] = None, + factory: Factory[T] | None = None, ) -> None: super().__init__(keys, desc) self.of_type = of_type diff --git a/src/tox/config/sets.py b/src/tox/config/sets.py index 098901c43..68e9d0fa6 100644 --- a/src/tox/config/sets.py +++ b/src/tox/config/sets.py @@ -47,7 +47,7 @@ def add_config( # noqa: PLR0913 default: Callable[[Config, str | None], V] | V, desc: str, post_process: Callable[[V], V] | None = None, - factory: Factory[Any] = None, + factory: Factory[Any] | None = None, ) -> ConfigDynamicDefinition[V]: """ Add configuration value. diff --git a/src/tox/plugin/inline.py b/src/tox/plugin/inline.py index cf4511f51..12a1b5174 100644 --- a/src/tox/plugin/inline.py +++ b/src/tox/plugin/inline.py @@ -27,7 +27,6 @@ def _load_plugin(path: Path) -> ModuleType: try: if module_name in sys.modules: del sys.modules[module_name] # pragma: no cover - module = importlib.import_module(module_name) - return module + return importlib.import_module(module_name) finally: del sys.path[0] diff --git a/src/tox/run.py b/src/tox/run.py index 5d94d458f..fa420006b 100644 --- a/src/tox/run.py +++ b/src/tox/run.py @@ -42,8 +42,7 @@ def main(args: Sequence[str]) -> int: if result is not False: return result handler = state._options.cmd_handlers[state.conf.options.command] # noqa: SLF001 - result = handler(state) - return result + return handler(state) def setup_state(args: Sequence[str]) -> State: diff --git a/src/tox/session/env_select.py b/src/tox/session/env_select.py index 23de3a711..127606b04 100644 --- a/src/tox/session/env_select.py +++ b/src/tox/session/env_select.py @@ -47,7 +47,7 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}({'' if self.is_default_list else repr(str(self))})" def __eq__(self, other: Any) -> bool: - return type(self) == type(other) and self._names == other._names # noqa: SLF001 + return type(self) == type(other) and self._names == other._names def __ne__(self, other: Any) -> bool: return not (self == other) diff --git a/src/tox/tox_env/python/pip/req/file.py b/src/tox/tox_env/python/pip/req/file.py index 09dccac2d..e307729fb 100644 --- a/src/tox/tox_env/python/pip/req/file.py +++ b/src/tox/tox_env/python/pip/req/file.py @@ -246,8 +246,7 @@ def _get_file_content(self, url: str) -> str: scheme = get_url_scheme(url) if scheme in ["http", "https"]: with urlopen(url) as response: # noqa: S310 - text = self._read_decode(response) - return text + return self._read_decode(response) elif scheme == "file": url = url_to_path(url) try: @@ -275,8 +274,7 @@ def _pre_process(self, content: str) -> ReqFileLines: lines_enum: ReqFileLines = enumerate(content.splitlines(), start=1) lines_enum = self._join_lines(lines_enum) lines_enum = self._ignore_comments(lines_enum) - lines_enum = self._expand_env_variables(lines_enum) - return lines_enum + return self._expand_env_variables(lines_enum) def _parse_line(self, line: str) -> tuple[str, Namespace]: args_str, options_str = self._break_args_options(line) diff --git a/src/tox/tox_env/python/pip/req/util.py b/src/tox/tox_env/python/pip/req/util.py index 8e4d38ac5..23cec4029 100644 --- a/src/tox/tox_env/python/pip/req/util.py +++ b/src/tox/tox_env/python/pip/req/util.py @@ -27,8 +27,7 @@ def url_to_path(url: str) -> str: else: msg = f"non-local file URIs are not supported on this platform: {url!r}" raise ValueError(msg) - path = url2pathname(netloc + path) - return path + return url2pathname(netloc + path) def handle_binary_option(value: str, target: set[str], other: set[str]) -> None: diff --git a/src/tox/tox_env/python/pip/req_file.py b/src/tox/tox_env/python/pip/req_file.py index 5bf41fe07..ed4fc7c8a 100644 --- a/src/tox/tox_env/python/pip/req_file.py +++ b/src/tox/tox_env/python/pip/req_file.py @@ -70,8 +70,7 @@ def _normalize_raw(raw: str) -> str: # for tox<4 supporting requirement/constraint files via -rreq.txt/-creq.txt lines.append(PythonDeps._normalize_line(line)) adjusted = "\n".join(lines) - raw = f"{adjusted}\n" if raw.endswith("\\\n") else adjusted # preserve trailing newline if input has it - return raw + return f"{adjusted}\n" if raw.endswith("\\\n") else adjusted # preserve trailing newline if input has it @staticmethod def _normalize_line(line: str) -> str: