Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#2598)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
pre-commit-ci[bot] and gaborbernat committed Jul 3, 2023
1 parent 9f9dc62 commit 7d68360
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: prettier
args: ["--print-width=120", "--prose-wrap=always"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.275"
rev: "v0.0.276"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 1 addition & 3 deletions docs/render_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def run(self):
core_result = parse_parser(parser_creator())
core_result["action_groups"] = [i for i in core_result["action_groups"] if i["title"] not in CUSTOM]

content = []
for i in core_result["action_groups"]:
content.append(self._build_table(i["options"], i["title"], i["description"]))
content = [self._build_table(i["options"], i["title"], i["description"]) for i in core_result["action_groups"]]
for key, name_to_class in CUSTOM.items():
section = n.section("", ids=[f"section-{key}"])
title = n.title("", key)
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/create/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def non_write_able(dest, value):
if trip == char:
continue
raise ValueError(trip) # noqa: TRY301
except ValueError:
except ValueError: # noqa: PERF203
refused[char] = None
if refused:
bad = "".join(refused.keys())
Expand Down
4 changes: 2 additions & 2 deletions src/virtualenv/discovery/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def propose_interpreters(spec, try_first_with, app_data, env=None): # noqa: C90
path = os.path.abspath(py_exe)
try:
os.lstat(path) # Windows Store Python does not work with os.path.exists, but does for os.lstat
except OSError:
except OSError: # noqa: PERF203
pass
else:
yield PythonInfo.from_exe(os.path.abspath(path), app_data, env=env), True
Expand Down Expand Up @@ -145,7 +145,7 @@ def __repr__(self) -> str:
file_path = os.path.join(self.path, file_name)
if os.path.isdir(file_path) or not os.access(file_path, os.X_OK):
continue
except OSError:
except OSError: # noqa: PERF203
pass
content += " "
content += file_name
Expand Down
6 changes: 2 additions & 4 deletions src/virtualenv/discovery/windows/pep514.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def enum_keys(key):
while True:
try:
yield winreg.EnumKey(key, at)
except OSError:
except OSError: # noqa: PERF203
break
at += 1

Expand Down Expand Up @@ -144,9 +144,7 @@ def msg(path, what):

def _run():
basicConfig()
interpreters = []
for spec in discover_pythons():
interpreters.append(repr(spec))
interpreters = [repr(spec) for spec in discover_pythons()]
print("\n".join(sorted(interpreters))) # noqa: T201


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _generate_new_files(self):
rel = file.relative_to(self._image_dir)
if len(rel.parts) > 1:
continue
except ValueError:
except ValueError: # noqa: PERF203
pass
new_files.add(file)
return new_files
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/seed/embed/via_app_data/via_app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _get(distribution, version):
)
if result is not None:
break
except Exception as exception:
except Exception as exception: # noqa: PERF203
logging.exception("fail")
failure = exception
if failure:
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/seed/wheels/periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def _pypi_get_distribution_info(distribution):
with urlopen(url, context=context) as file_handler: # noqa: S310
content = json.load(file_handler)
break
except URLError as exception:
except URLError as exception: # noqa: PERF203
logging.error("failed to access %s because %r", url, exception) # noqa: TRY400
except Exception as exception: # noqa: BLE001
logging.error("failed to access %s because %r", url, exception) # noqa: TRY400
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/seed/wheels/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def as_version_tuple(version):
for part in version.split(".")[0:3]:
try:
result.append(int(part))
except ValueError:
except ValueError: # noqa: PERF203
break
if not result:
raise ValueError(version)
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/util/path/_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def make_exe(filename):
mode |= level
filename.chmod(mode)
break
except OSError:
except OSError: # noqa: PERF203
continue


Expand Down
10 changes: 5 additions & 5 deletions tasks/make_zipapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ def get_dependencies(whl, version):

@staticmethod
def _marker_at(markers, key):
positions = []
for i, m in enumerate(markers):
if isinstance(m, tuple) and len(m) == 3 and m[0].value == key: # noqa: PLR2004
positions.append(i)
return positions
return [
i
for i, m in enumerate(markers)
if isinstance(m, tuple) and len(m) == 3 and m[0].value == key # noqa: PLR2004
]

@staticmethod
def _del_marker_at(markers, at):
Expand Down
4 changes: 2 additions & 2 deletions tasks/upgrade_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def run(): # noqa: C901
del removed[key]
lines.append(text)
for key, versions in removed.items():
lines.append(f"Removed {key} of {fmt_version(versions)}")
lines.append(f"Removed {key} of {fmt_version(versions)}") # noqa: PERF401
lines.append("")
changelog = "\n".join(lines)
print(changelog) # noqa: T201
Expand All @@ -87,7 +87,7 @@ def run(): # noqa: C901
for package in sorted(new_batch.keys()):
for folder, version in sorted(folders.items()):
if (folder / package).exists():
support_table[version].append(package)
support_table[version].append(package) # noqa: PERF401
support_table = {k: OrderedDict((i.split("-")[0], i) for i in v) for k, v in support_table.items()}
bundle = ",".join(
f"{v!r}: {{ {','.join(f'{p!r}: {f!r}' for p, f in line.items())} }}" for v, line in support_table.items()
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def special_char_name():
trip = char.encode(encoding, errors="strict").decode(encoding)
if char == trip:
result += char
except ValueError:
except ValueError: # noqa: PERF203
continue
assert result
return result
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/seed/wheels/test_periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def _do_update( # noqa: PLR0913
assert " new entries found:\n" in caplog.text
assert "\tNewVersion(" in caplog.text
packages = defaultdict(list)
for i in do_update_mock.call_args_list:
packages[i[1]["distribution"]].append(i[1]["for_py_version"])
for args in do_update_mock.call_args_list:
packages[args[1]["distribution"]].append(args[1]["for_py_version"]) # noqa: PERF401
packages = {key: sorted(value) for key, value in packages.items()}
versions = sorted(BUNDLE_SUPPORT.keys())
expected = {"setuptools": versions, "wheel": versions, "pip": versions}
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ def recreate_target_file():
target_file.touch()

with concurrent.futures.ThreadPoolExecutor() as executor:
tasks = []
for _ in range(4):
tasks.append(executor.submit(recreate_target_file))
tasks = [executor.submit(recreate_target_file) for _ in range(4)]
concurrent.futures.wait(tasks)
for task in tasks:
try:
task.result()
except Exception: # noqa: BLE001
except Exception: # noqa: BLE001, PERF203
pytest.fail(traceback.format_exc())

0 comments on commit 7d68360

Please sign in to comment.