Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate
Browse files Browse the repository at this point in the history
updates:
- [github.com/tox-dev/pyproject-fmt: 0.12.1 → 0.13.0](tox-dev/pyproject-fmt@0.12.1...0.13.0)
- [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode → v3.0.0](pre-commit/mirrors-prettier@v3.0.0-alpha.9-for-vscode...v3.0.0)
- [github.com/asottile/blacken-docs: 1.14.0 → 1.15.0](adamchainz/blacken-docs@1.14.0...1.15.0)
- [github.com/astral-sh/ruff-pre-commit: v0.0.275 → v0.0.277](astral-sh/ruff-pre-commit@v0.0.275...v0.0.277)

Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
pre-commit-ci[bot] authored and gaborbernat committed Jul 10, 2023
1 parent c2613ca commit 09ade01
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 34 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/tox/config/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tox/config/loader/ini/replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/tox/config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tox/config/of_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/tox/config/source/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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

Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/tox/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/cmd/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/cmd/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 1 addition & 3 deletions src/tox/session/cmd/run/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/cmd/run/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/cmd/show_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tox/tox_env/python/pip/req/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", []):
Expand Down
6 changes: 2 additions & 4 deletions src/tox/tox_env/python/pip/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/tox/util/spinner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/plugin/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 09ade01

Please sign in to comment.