Skip to content

Commit 506ea41

Browse files
authored
STY: Use zip for conciseness (#3027)
Also tweak an assert statement.
1 parent 94c434e commit 506ea41

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

pypdf/_utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,10 @@ def __eq__(self, other: object) -> bool:
581581
def __lt__(self, other: Any) -> bool:
582582
if not isinstance(other, Version):
583583
raise ValueError(f"Version cannot be compared against {type(other)}")
584-
min_len = min(len(self.components), len(other.components))
585-
for i in range(min_len):
586-
self_value, self_suffix = self.components[i]
587-
other_value, other_suffix = other.components[i]
584+
585+
for self_component, other_component in zip(self.components, other.components):
586+
self_value, self_suffix = self_component
587+
other_value, other_suffix = other_component
588588

589589
if self_value < other_value:
590590
return True

tests/test_utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -353,22 +353,22 @@ def test_is_sublist():
353353
("1", "1", False),
354354
("1.0", "1.1", True),
355355
("1", "1.1", True),
356-
# suffix left
356+
# Suffix left
357357
("1a", "2", True),
358358
("2a", "1", False),
359359
("1a", "1", False),
360360
("1.0a", "1.1", True),
361-
# I'm not sure about that, but seems special enoguht that it
361+
# I'm not sure about that, but seems special enough that it
362362
# probably doesn't matter:
363363
("1a", "1.1", False),
364-
# suffix right
364+
# Suffix right
365365
("1", "2a", True),
366366
("2", "1a", False),
367367
("1", "1a", True),
368368
("1.0", "1.1a", True),
369369
("1", "1.1a", True),
370370
("", "0.0.0", True),
371-
# just suffix matters ... hm, I think this is actually wrong:
371+
# Just suffix matters ... hm, I think this is actually wrong:
372372
("1.0a", "1.0", False),
373373
("1.0", "1.0a", True),
374374
],
@@ -379,7 +379,7 @@ def test_version_compare(left, right, is_less_than):
379379

380380
def test_version_compare_equal_str():
381381
a = Version("1.0")
382-
assert (a == "1.0") is False
382+
assert a != "1.0"
383383

384384

385385
def test_version_compare_lt_str():

0 commit comments

Comments
 (0)