Skip to content

Commit 7d68360

Browse files
[pre-commit.ci] pre-commit autoupdate (#2598)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bernát Gábor <[email protected]>
1 parent 9f9dc62 commit 7d68360

File tree

15 files changed

+24
-30
lines changed

15 files changed

+24
-30
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
- id: prettier
2525
args: ["--print-width=120", "--prose-wrap=always"]
2626
- repo: https://github.com/astral-sh/ruff-pre-commit
27-
rev: "v0.0.275"
27+
rev: "v0.0.276"
2828
hooks:
2929
- id: ruff
3030
args: [--fix, --exit-non-zero-on-fix]

docs/render_cli.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def run(self):
3434
core_result = parse_parser(parser_creator())
3535
core_result["action_groups"] = [i for i in core_result["action_groups"] if i["title"] not in CUSTOM]
3636

37-
content = []
38-
for i in core_result["action_groups"]:
39-
content.append(self._build_table(i["options"], i["title"], i["description"]))
37+
content = [self._build_table(i["options"], i["title"], i["description"]) for i in core_result["action_groups"]]
4038
for key, name_to_class in CUSTOM.items():
4139
section = n.section("", ids=[f"section-{key}"])
4240
title = n.title("", key)

src/virtualenv/create/creator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def non_write_able(dest, value):
121121
if trip == char:
122122
continue
123123
raise ValueError(trip) # noqa: TRY301
124-
except ValueError:
124+
except ValueError: # noqa: PERF203
125125
refused[char] = None
126126
if refused:
127127
bad = "".join(refused.keys())

src/virtualenv/discovery/builtin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def propose_interpreters(spec, try_first_with, app_data, env=None): # noqa: C90
7777
path = os.path.abspath(py_exe)
7878
try:
7979
os.lstat(path) # Windows Store Python does not work with os.path.exists, but does for os.lstat
80-
except OSError:
80+
except OSError: # noqa: PERF203
8181
pass
8282
else:
8383
yield PythonInfo.from_exe(os.path.abspath(path), app_data, env=env), True
@@ -145,7 +145,7 @@ def __repr__(self) -> str:
145145
file_path = os.path.join(self.path, file_name)
146146
if os.path.isdir(file_path) or not os.access(file_path, os.X_OK):
147147
continue
148-
except OSError:
148+
except OSError: # noqa: PERF203
149149
pass
150150
content += " "
151151
content += file_name

src/virtualenv/discovery/windows/pep514.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def enum_keys(key):
1515
while True:
1616
try:
1717
yield winreg.EnumKey(key, at)
18-
except OSError:
18+
except OSError: # noqa: PERF203
1919
break
2020
at += 1
2121

@@ -144,9 +144,7 @@ def msg(path, what):
144144

145145
def _run():
146146
basicConfig()
147-
interpreters = []
148-
for spec in discover_pythons():
149-
interpreters.append(repr(spec))
147+
interpreters = [repr(spec) for spec in discover_pythons()]
150148
print("\n".join(sorted(interpreters))) # noqa: T201
151149

152150

src/virtualenv/seed/embed/via_app_data/pip_install/symlink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _generate_new_files(self):
3232
rel = file.relative_to(self._image_dir)
3333
if len(rel.parts) > 1:
3434
continue
35-
except ValueError:
35+
except ValueError: # noqa: PERF203
3636
pass
3737
new_files.add(file)
3838
return new_files

src/virtualenv/seed/embed/via_app_data/via_app_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _get(distribution, version):
9393
)
9494
if result is not None:
9595
break
96-
except Exception as exception:
96+
except Exception as exception: # noqa: PERF203
9797
logging.exception("fail")
9898
failure = exception
9999
if failure:

src/virtualenv/seed/wheels/periodic_update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def _pypi_get_distribution_info(distribution):
350350
with urlopen(url, context=context) as file_handler: # noqa: S310
351351
content = json.load(file_handler)
352352
break
353-
except URLError as exception:
353+
except URLError as exception: # noqa: PERF203
354354
logging.error("failed to access %s because %r", url, exception) # noqa: TRY400
355355
except Exception as exception: # noqa: BLE001
356356
logging.error("failed to access %s because %r", url, exception) # noqa: TRY400

src/virtualenv/seed/wheels/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def as_version_tuple(version):
3535
for part in version.split(".")[0:3]:
3636
try:
3737
result.append(int(part))
38-
except ValueError:
38+
except ValueError: # noqa: PERF203
3939
break
4040
if not result:
4141
raise ValueError(version)

src/virtualenv/util/path/_permission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def make_exe(filename):
1414
mode |= level
1515
filename.chmod(mode)
1616
break
17-
except OSError:
17+
except OSError: # noqa: PERF203
1818
continue
1919

2020

tasks/make_zipapp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ def get_dependencies(whl, version):
188188

189189
@staticmethod
190190
def _marker_at(markers, key):
191-
positions = []
192-
for i, m in enumerate(markers):
193-
if isinstance(m, tuple) and len(m) == 3 and m[0].value == key: # noqa: PLR2004
194-
positions.append(i)
195-
return positions
191+
return [
192+
i
193+
for i, m in enumerate(markers)
194+
if isinstance(m, tuple) and len(m) == 3 and m[0].value == key # noqa: PLR2004
195+
]
196196

197197
@staticmethod
198198
def _del_marker_at(markers, at):

tasks/upgrade_wheels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def run(): # noqa: C901
7777
del removed[key]
7878
lines.append(text)
7979
for key, versions in removed.items():
80-
lines.append(f"Removed {key} of {fmt_version(versions)}")
80+
lines.append(f"Removed {key} of {fmt_version(versions)}") # noqa: PERF401
8181
lines.append("")
8282
changelog = "\n".join(lines)
8383
print(changelog) # noqa: T201
@@ -87,7 +87,7 @@ def run(): # noqa: C901
8787
for package in sorted(new_batch.keys()):
8888
for folder, version in sorted(folders.items()):
8989
if (folder / package).exists():
90-
support_table[version].append(package)
90+
support_table[version].append(package) # noqa: PERF401
9191
support_table = {k: OrderedDict((i.split("-")[0], i) for i in v) for k, v in support_table.items()}
9292
bundle = ",".join(
9393
f"{v!r}: {{ {','.join(f'{p!r}: {f!r}' for p, f in line.items())} }}" for v, line in support_table.items()

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def special_char_name():
285285
trip = char.encode(encoding, errors="strict").decode(encoding)
286286
if char == trip:
287287
result += char
288-
except ValueError:
288+
except ValueError: # noqa: PERF203
289289
continue
290290
assert result
291291
return result

tests/unit/seed/wheels/test_periodic_update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def _do_update( # noqa: PLR0913
7070
assert " new entries found:\n" in caplog.text
7171
assert "\tNewVersion(" in caplog.text
7272
packages = defaultdict(list)
73-
for i in do_update_mock.call_args_list:
74-
packages[i[1]["distribution"]].append(i[1]["for_py_version"])
73+
for args in do_update_mock.call_args_list:
74+
packages[args[1]["distribution"]].append(args[1]["for_py_version"]) # noqa: PERF401
7575
packages = {key: sorted(value) for key, value in packages.items()}
7676
versions = sorted(BUNDLE_SUPPORT.keys())
7777
expected = {"setuptools": versions, "wheel": versions, "pip": versions}

tests/unit/test_util.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ def recreate_target_file():
2727
target_file.touch()
2828

2929
with concurrent.futures.ThreadPoolExecutor() as executor:
30-
tasks = []
31-
for _ in range(4):
32-
tasks.append(executor.submit(recreate_target_file))
30+
tasks = [executor.submit(recreate_target_file) for _ in range(4)]
3331
concurrent.futures.wait(tasks)
3432
for task in tasks:
3533
try:
3634
task.result()
37-
except Exception: # noqa: BLE001
35+
except Exception: # noqa: BLE001, PERF203
3836
pytest.fail(traceback.format_exc())

0 commit comments

Comments
 (0)