Skip to content

Commit 45a934c

Browse files
committed
Merge branch 'mr/fix_UP034_rule' into 'master'
Fix UP034 rule See merge request it/e3-core!219
2 parents 0d1117c + 6de1459 commit 45a934c

File tree

5 files changed

+19
-30
lines changed

5 files changed

+19
-30
lines changed

src/e3/anod/qualifiers_manager.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def __init__(
135135

136136
# Check that default value is valid
137137
if default is not None and choices is not None and default not in choices:
138-
choices_str = ", ".join((f"'{choice}'" for choice in choices))
138+
choices_str = ", ".join(f"'{choice}'" for choice in choices)
139139
raise AnodError(
140140
f"{self.origin}: default value '{default}' "
141141
f"should be in ({choices_str})."
@@ -162,7 +162,7 @@ def value(self, value: QualifierValue | None) -> QualifierValue:
162162
)
163163

164164
if self.choices is not None and value not in self.choices:
165-
choices_str = ", ".join((f"'{choice}'" for choice in self.choices))
165+
choices_str = ", ".join(f"'{choice}'" for choice in self.choices)
166166
raise AnodError(
167167
f"{self.origin}: Invalid value for qualifier {self.name}: '{value}' "
168168
f"not in ({choices_str})"
@@ -276,9 +276,9 @@ def __init__(
276276
if default is not None and choices is not None:
277277
wrong_values = default - set(choices)
278278
if wrong_values:
279-
choices_str = ", ".join((f"'{choice}'" for choice in choices))
279+
choices_str = ", ".join(f"'{choice}'" for choice in choices)
280280
wrong_values_str = ", ".join(
281-
(f"'{value}'" for value in sorted(wrong_values))
281+
f"'{value}'" for value in sorted(wrong_values)
282282
)
283283
raise AnodError(
284284
f"{self.origin}: In '{self.name}', default value(s) "
@@ -314,7 +314,7 @@ def value(self, value: QualifierValue | None) -> QualifierValue:
314314
)
315315
else:
316316
try:
317-
result = all((isinstance(el, str) for el in value))
317+
result = all(isinstance(el, str) for el in value)
318318
if not result:
319319
raise AnodError(
320320
f"{self.origin}: Invalid value for qualifier {self.name}: "
@@ -336,9 +336,9 @@ def value(self, value: QualifierValue | None) -> QualifierValue:
336336
wrong_values = value_set - set(self.choices)
337337

338338
if wrong_values:
339-
choices_str = ", ".join((f"'{choice}'" for choice in self.choices))
339+
choices_str = ", ".join(f"'{choice}'" for choice in self.choices)
340340
wrong_values_str = ", ".join(
341-
(f"'{value}'" for value in sorted(wrong_values))
341+
f"'{value}'" for value in sorted(wrong_values)
342342
)
343343
raise AnodError(
344344
f"{self.origin}: Invalid value(s) for qualifier {self.name}: "
@@ -359,7 +359,7 @@ def repr(self, value: QualifierValue, hash_pool: list[str] | None) -> str:
359359
list_repr = []
360360
if not self.repr_omit_key:
361361
list_repr.append(self.repr_name)
362-
list_repr.extend((str(v) for v in sorted(value)))
362+
list_repr.extend(str(v) for v in sorted(value))
363363

364364
# And join them with a dash.
365365
str_repr = "-".join(list_repr)

src/e3/anod/store/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,10 +2192,7 @@ def bulk_update_from_store(
21922192
all_results = []
21932193

21942194
for index, store_queries_chunk in enumerate(
2195-
(
2196-
queries_done[i : i + chunk_size]
2197-
for i in range(0, queries_num, chunk_size)
2198-
)
2195+
queries_done[i : i + chunk_size] for i in range(0, queries_num, chunk_size)
21992196
):
22002197
start_time = time.time()
22012198
logger.debug(f" Query chunk {index + 1}/{chunk_num}")

src/e3/diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def write_line(line: str) -> None:
236236
# This is the start of patch. Decide whether to discard it or
237237
# not
238238
path_list = [header1[1], header2[1]]
239-
discard = any((discard_patch(fn) for fn in path_list))
239+
discard = any(discard_patch(fn) for fn in path_list)
240240

241241
if not discard:
242242
files_to_patch += 1
@@ -268,7 +268,7 @@ def process_git_patch() -> int:
268268
if m is not None:
269269
# This is the start of a git patch
270270
path_list = [m.group(1), m.group(2)]
271-
discard = any((discard_patch(fn) for fn in path_list))
271+
discard = any(discard_patch(fn) for fn in path_list)
272272

273273
if not discard:
274274
files_to_patch += 1

src/e3/python/pypi.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,9 @@ def is_compatible_with_platforms(self, platform_list: list[str]) -> bool:
494494
platforms_regex.append("win32")
495495

496496
result = any(
497-
(
498-
platform
499-
for platform in self.platform_tags
500-
if re.match("|".join(platforms_regex), platform)
501-
)
497+
platform
498+
for platform in self.platform_tags
499+
if re.match("|".join(platforms_regex), platform)
502500
)
503501
return result
504502

@@ -513,11 +511,7 @@ def is_compatible_with_cpython3(self, minor_version: int) -> bool:
513511
else:
514512
result = (
515513
any(
516-
(
517-
tag
518-
for tag in self.py_tags
519-
if tag in ("py3", f"cp3{minor_version}")
520-
)
514+
tag for tag in self.py_tags if tag in ("py3", f"cp3{minor_version}")
521515
)
522516
or "abi3" in self.abi_tags
523517
)
@@ -698,11 +692,9 @@ def file_closure(self) -> list[str]:
698692
# First check if there is a generic wheel present or no. If there is
699693
# one then there is no need to package the sources.
700694
has_generic_wheel = any(
701-
(
702-
c
703-
for c in self.pypi.candidate_cache[canonicalize_name(req.name)]
704-
if c.is_generic_wheel and c.version in req.specifier
705-
)
695+
c
696+
for c in self.pypi.candidate_cache[canonicalize_name(req.name)]
697+
if c.is_generic_wheel and c.version in req.specifier
706698
)
707699

708700
for candidate in self.pypi.candidate_cache[canonicalize_name(req.name)]:

tests/tests_e3/spdx_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def test_misc_from_json_dict() -> None:
584584
PackageChecksum.from_json_dict({})
585585
with pytest.raises(ValueError, match="Unsupported checksum algorithm"):
586586
PackageChecksum.from_json_dict(
587-
({"algorithm": "invalid", "checksumValue": "not checked"})
587+
{"algorithm": "invalid", "checksumValue": "not checked"}
588588
)
589589
homepage: PackageHomePage | None = PackageHomePage.from_json_dict(
590590
{PackageHomePage.get_json_entry_key(): "homepage"}

0 commit comments

Comments
 (0)