From 09ade0163bc74f2db5d7a6593c036175eb529d64 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 17:46:43 +0000 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/tox-dev/pyproject-fmt: 0.12.1 → 0.13.0](https://github.com/tox-dev/pyproject-fmt/compare/0.12.1...0.13.0) - [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode → v3.0.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.0-alpha.9-for-vscode...v3.0.0) - [github.com/asottile/blacken-docs: 1.14.0 → 1.15.0](https://github.com/asottile/blacken-docs/compare/1.14.0...1.15.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.275 → v0.0.277](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.275...v0.0.277) Signed-off-by: Bernát Gábor --- .pre-commit-config.yaml | 10 +++++----- pyproject.toml | 6 +++--- src/tox/config/cli/parser.py | 2 +- src/tox/config/loader/ini/replace.py | 2 +- src/tox/config/main.py | 2 +- src/tox/config/of_type.py | 2 +- src/tox/config/source/discover.py | 6 +++--- src/tox/provision.py | 2 +- src/tox/session/cmd/depends.py | 2 +- src/tox/session/cmd/legacy.py | 2 +- src/tox/session/cmd/run/common.py | 4 +--- src/tox/session/cmd/run/single.py | 2 +- src/tox/session/cmd/show_config.py | 2 +- src/tox/tox_env/python/pip/req/file.py | 2 +- src/tox/tox_env/python/pip/req_file.py | 6 ++---- src/tox/util/spinner.py | 8 ++++---- tests/plugin/test_plugin.py | 2 +- tox.ini | 2 +- 18 files changed, 30 insertions(+), 34 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8a033ba2..44c84bc27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,22 +14,22 @@ repos: - id: tox-ini-fmt args: ["-p", "fix"] - repo: https://github.com/tox-dev/pyproject-fmt - rev: "0.12.1" + rev: "0.13.0" hooks: - id: pyproject-fmt - additional_dependencies: ["tox>=4.6.3"] + additional_dependencies: ["tox>=4.6.4"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.9-for-vscode" + rev: "v3.0.0" hooks: - id: prettier args: ["--print-width=120", "--prose-wrap=always"] - repo: https://github.com/asottile/blacken-docs - rev: 1.14.0 + rev: 1.15.0 hooks: - id: blacken-docs additional_dependencies: [black==23.3] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.275" + rev: "v0.0.277" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/pyproject.toml b/pyproject.toml index 5da0dcf15..fb807f510 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,11 +54,11 @@ dependencies = [ "filelock>=3.12.2", 'importlib-metadata>=6.7; python_version < "3.8"', "packaging>=23.1", - "platformdirs>=3.8", + "platformdirs>=3.8.1", "pluggy>=1.2", - "pyproject-api>=1.5.2", + "pyproject-api>=1.5.3", 'tomli>=2.0.1; python_version < "3.11"', - 'typing-extensions>=4.6.3; python_version < "3.8"', + 'typing-extensions>=4.7.1; python_version < "3.8"', "virtualenv>=20.23.1", ] optional-dependencies.docs = [ diff --git a/src/tox/config/cli/parser.py b/src/tox/config/cli/parser.py index 25990f843..b06b10ae8 100644 --- a/src/tox/config/cli/parser.py +++ b/src/tox/config/cli/parser.py @@ -64,7 +64,7 @@ def get_type(action: Action) -> type[Any]: loc = locals() loc["Literal"] = Literal as_literal = f"Literal[{', '.join(repr(i) for i in action.choices)}]" - of_type = eval(as_literal, globals(), loc) # noqa: PGH001 + of_type = eval(as_literal, globals(), loc) # noqa: PGH001, S307 elif action.default is not None: of_type = type(action.default) elif isinstance(action, argparse._StoreConstAction) and action.const is not None: # noqa: SLF001 diff --git a/src/tox/config/loader/ini/replace.py b/src/tox/config/loader/ini/replace.py index 9d9373989..f72db8f16 100644 --- a/src/tox/config/loader/ini/replace.py +++ b/src/tox/config/loader/ini/replace.py @@ -255,7 +255,7 @@ def replace_reference( # noqa: PLR0912, C901 if isinstance(src, SectionProxy): return loader.process_raw(conf, conf_args.env_name, src[key]) value = src.load(key, conf_args.chain) - except KeyError as exc: # if fails, keep trying maybe another source can satisfy + except KeyError as exc: # if fails, keep trying maybe another source can satisfy # noqa: PERF203 exception = exc else: as_str, _ = stringify(value) diff --git a/src/tox/config/main.py b/src/tox/config/main.py index a073911bb..50a026b66 100644 --- a/src/tox/config/main.py +++ b/src/tox/config/main.py @@ -140,7 +140,7 @@ def get_section_config( # noqa: PLR0913 if for_env is not None: conf_set.loaders.extend(self.memory_seed_loaders.get(for_env, [])) for loader in self._src.get_loaders(section, base, self._overrides, conf_set): - conf_set.loaders.append(loader) + conf_set.loaders.append(loader) # noqa: PERF402 if loaders is not None: conf_set.loaders.extend(loaders) return conf_set diff --git a/src/tox/config/of_type.py b/src/tox/config/of_type.py index 6c01a1231..46f8379f0 100644 --- a/src/tox/config/of_type.py +++ b/src/tox/config/of_type.py @@ -95,7 +95,7 @@ def __call__( args.chain.append(chain_key) try: value = loader.load(key, self.of_type, self.factory, conf, args) - except KeyError: + except KeyError: # noqa: PERF203 continue else: break diff --git a/src/tox/config/source/discover.py b/src/tox/config/source/discover.py index 42bcba81a..4128a8171 100644 --- a/src/tox/config/source/discover.py +++ b/src/tox/config/source/discover.py @@ -36,7 +36,7 @@ def discover_source(config_file: Path | None, root_dir: Path | None) -> Source: try: src = src_type(candidate) break - except ValueError: + except ValueError: # noqa: PERF203 continue if src is None: msg = f"could not find any config file in {config_file}" @@ -53,7 +53,7 @@ def _locate_source() -> Source | None: candidate: Path = base / src_type.FILENAME try: return src_type(candidate) - except ValueError: + except ValueError: # noqa: PERF203 pass return None @@ -64,7 +64,7 @@ def _load_exact_source(config_file: Path) -> Source: for src_type in (exact_match,) if exact_match is not None else SOURCE_TYPES: # pragma: no branch try: return src_type(config_file) - except ValueError: + except ValueError: # noqa: PERF203 pass msg = f"could not recognize config file {config_file}" raise HandledError(msg) diff --git a/src/tox/provision.py b/src/tox/provision.py index 1b7670602..c8720541c 100644 --- a/src/tox/provision.py +++ b/src/tox/provision.py @@ -132,7 +132,7 @@ def _get_missing(requires: list[Requirement]) -> list[tuple[Requirement, str | N package_name = canonicalize_name(package.name) try: dist = distribution(package_name) - except PackageNotFoundError: + except PackageNotFoundError: # noqa: PERF203 missing.append((package, None)) else: if not package.specifier.contains(dist.version, prereleases=True): diff --git a/src/tox/session/cmd/depends.py b/src/tox/session/cmd/depends.py index 5bb42c4b1..09f519752 100644 --- a/src/tox/session/cmd/depends.py +++ b/src/tox/session/cmd/depends.py @@ -38,7 +38,7 @@ def _handle(at: int, env: str) -> None: packager_list: list[str] = [] try: for pkg_env in run_env.package_envs: - packager_list.append(pkg_env.name) + packager_list.append(pkg_env.name) # noqa: PERF401 except Exception as exception: # noqa: BLE001 packager_list.append(f"... ({exception})") names = " | ".join(packager_list) diff --git a/src/tox/session/cmd/legacy.py b/src/tox/session/cmd/legacy.py index 92a91fcf7..5982cdb70 100644 --- a/src/tox/session/cmd/legacy.py +++ b/src/tox/session/cmd/legacy.py @@ -139,7 +139,7 @@ def _handle_legacy_only_flags(option: Parsed, envs: EnvSelector) -> None: # noq for at, entry in enumerate(as_root_args): try: req = Requirement(entry) - except InvalidRequirement: + except InvalidRequirement: # noqa: PERF203 continue if req.name in to_force: as_root_args[at] = str(to_force[req.name]) diff --git a/src/tox/session/cmd/run/common.py b/src/tox/session/cmd/run/common.py index d943fc860..f61a45a4f 100644 --- a/src/tox/session/cmd/run/common.py +++ b/src/tox/session/cmd/run/common.py @@ -263,10 +263,8 @@ def execute(state: State, max_workers: int | None, has_spinner: bool, live: bool thread._stop() # type: ignore[attr-defined] # pragma: no cover # noqa: SLF001 thread.join() finally: - ordered_results: list[ToxEnvRunResult] = [] name_to_run = {r.name: r for r in results} - for env in to_run_list: - ordered_results.append(name_to_run[env]) + ordered_results: list[ToxEnvRunResult] = [name_to_run[env] for env in to_run_list] # write the journal write_journal(getattr(state.conf.options, "result_json", None), state._journal) # noqa: SLF001 # report the outcome diff --git a/src/tox/session/cmd/run/single.py b/src/tox/session/cmd/run/single.py index 5549256dc..037b48663 100644 --- a/src/tox/session/cmd/run/single.py +++ b/src/tox/session/cmd/run/single.py @@ -112,7 +112,7 @@ def run_command_set( outcomes.append(current_outcome) try: current_outcome.assert_success() - except SystemExit as exception: + except SystemExit as exception: # noqa: PERF203 if cmd.ignore_exit_code: logging.warning("command failed but is marked ignore outcome so handling it as success") continue diff --git a/src/tox/session/cmd/show_config.py b/src/tox/session/cmd/show_config.py index e2d3f45f4..2ca2e9805 100644 --- a/src/tox/session/cmd/show_config.py +++ b/src/tox/session/cmd/show_config.py @@ -101,7 +101,7 @@ def print_conf(is_colored: bool, conf: ConfigSet, keys: Iterable[str]) -> None: try: value = conf[key] as_str, multi_line = stringify(value) - except Exception as exception: # because e.g. the interpreter cannot be found # noqa: BLE001 + except Exception as exception: # because e.g. the interpreter cannot be found # noqa: BLE001, PERF203 as_str, multi_line = _colored(is_colored, Fore.LIGHTRED_EX, f"# Exception: {exception!r}"), False if multi_line and "\n" not in as_str: multi_line = False diff --git a/src/tox/tox_env/python/pip/req/file.py b/src/tox/tox_env/python/pip/req/file.py index e307729fb..5a6b17849 100644 --- a/src/tox/tox_env/python/pip/req/file.py +++ b/src/tox/tox_env/python/pip/req/file.py @@ -320,7 +320,7 @@ def _merge_option_line( # noqa: C901, PLR0912, PLR0915 base_opt.features_enabled = [] for feature in opt.features_enabled: if feature not in base_opt.features_enabled: - base_opt.features_enabled.append(feature) + base_opt.features_enabled.append(feature) # noqa: PERF401 base_opt.features_enabled.sort() if opt.index_url: if getattr(base_opt, "index_url", []): diff --git a/src/tox/tox_env/python/pip/req_file.py b/src/tox/tox_env/python/pip/req_file.py index 55d9d36e4..a4266970e 100644 --- a/src/tox/tox_env/python/pip/req_file.py +++ b/src/tox/tox_env/python/pip/req_file.py @@ -66,10 +66,8 @@ def _normalize_raw(raw: str) -> str: # a line ending in an unescaped \ is treated as a line continuation and the newline following it is effectively # ignored raw = "".join(raw.replace("\r", "").split("\\\n")) - lines: list[str] = [] - for line in raw.splitlines(): - # for tox<4 supporting requirement/constraint files via -rreq.txt/-creq.txt - lines.append(PythonDeps._normalize_line(line)) + # for tox<4 supporting requirement/constraint files via -rreq.txt/-creq.txt + lines: list[str] = [PythonDeps._normalize_line(line) for line in raw.splitlines()] adjusted = "\n".join(lines) return f"{adjusted}\n" if raw.endswith("\\\n") else adjusted # preserve trailing newline if input has it diff --git a/src/tox/util/spinner.py b/src/tox/util/spinner.py index fb0cedde3..4fb6320a8 100644 --- a/src/tox/util/spinner.py +++ b/src/tox/util/spinner.py @@ -25,11 +25,11 @@ class _CursorInfo(ctypes.Structure): def _file_support_encoding(chars: Sequence[str], file: IO[str]) -> bool: encoding = getattr(file, "encoding", None) if encoding is not None: # pragma: no branch # this should be always set, unless someone passes in something bad - for char in chars: - try: + try: + for char in chars: char.encode(encoding) - except UnicodeEncodeError: - break + except UnicodeEncodeError: + pass else: return True return False diff --git a/tests/plugin/test_plugin.py b/tests/plugin/test_plugin.py index 227e85abb..f7a9aa50c 100644 --- a/tests/plugin/test_plugin.py +++ b/tests/plugin/test_plugin.py @@ -241,7 +241,7 @@ def _cannot_extend_config(config_set: ConfigSet) -> None: try: _conf(config_set) # type: ignore[no-untyped-call] # call to not typed function raise NotImplementedError # noqa: TRY301 - except RuntimeError as exc: + except RuntimeError as exc: # noqa: PERF203 assert str(exc) == "config set has been marked final and cannot be extended" # noqa: PT017 @impl diff --git a/tox.ini b/tox.ini index 0e28277f2..9f6557e61 100644 --- a/tox.ini +++ b/tox.ini @@ -84,7 +84,7 @@ commands = description = do a release, required posarg of the version number skip_install = true deps = - gitpython>=3.1.31 + gitpython>=3.1.32 packaging>=23.1 towncrier>=23.6 commands =