From 7eb2fda4f7af3bc2be92e5204c1098d0ddbcd557 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 8 Jan 2024 22:25:23 +0100 Subject: [PATCH] Run ruff formatter on existing code --- src/packaging/markers.py | 1 - src/packaging/specifiers.py | 6 ------ src/packaging/version.py | 2 -- tests/test_specifiers.py | 12 ++++-------- tests/test_version.py | 6 ++---- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/packaging/markers.py b/src/packaging/markers.py index 169493d3..c96d22a5 100644 --- a/src/packaging/markers.py +++ b/src/packaging/markers.py @@ -71,7 +71,6 @@ def _normalize_extra_values(results: Any) -> Any: def _format_marker( marker: Union[List[str], MarkerAtom, str], first: Optional[bool] = True ) -> str: - assert isinstance(marker, (list, tuple, str)) # Sometimes we have a structure like [[...]] which is a single item list diff --git a/src/packaging/specifiers.py b/src/packaging/specifiers.py index 94448327..61ad2e98 100644 --- a/src/packaging/specifiers.py +++ b/src/packaging/specifiers.py @@ -374,7 +374,6 @@ def _get_operator(self, op: str) -> CallableOperator: return operator_callable def _compare_compatible(self, prospective: Version, spec: str) -> bool: - # Compatible releases have an equivalent combination of >= and ==. That # is that ~=2.2 is equivalent to >=2.2,==2.*. This allows us to # implement this in terms of the other specifiers instead of @@ -395,7 +394,6 @@ def _compare_compatible(self, prospective: Version, spec: str) -> bool: ) def _compare_equal(self, prospective: Version, spec: str) -> bool: - # We need special logic to handle prefix matching if spec.endswith(".*"): # In the case of prefix matching we want to ignore local segment. @@ -439,21 +437,18 @@ def _compare_not_equal(self, prospective: Version, spec: str) -> bool: return not self._compare_equal(prospective, spec) def _compare_less_than_equal(self, prospective: Version, spec: str) -> bool: - # NB: Local version identifiers are NOT permitted in the version # specifier, so local version labels can be universally removed from # the prospective version. return Version(prospective.public) <= Version(spec) def _compare_greater_than_equal(self, prospective: Version, spec: str) -> bool: - # NB: Local version identifiers are NOT permitted in the version # specifier, so local version labels can be universally removed from # the prospective version. return Version(prospective.public) >= Version(spec) def _compare_less_than(self, prospective: Version, spec_str: str) -> bool: - # Convert our spec to a Version instance, since we'll want to work with # it as a version. spec = Version(spec_str) @@ -478,7 +473,6 @@ def _compare_less_than(self, prospective: Version, spec_str: str) -> bool: return True def _compare_greater_than(self, prospective: Version, spec_str: str) -> bool: - # Convert our spec to a Version instance, since we'll want to work with # it as a version. spec = Version(spec_str) diff --git a/src/packaging/version.py b/src/packaging/version.py index 5faab9bd..cda8e999 100644 --- a/src/packaging/version.py +++ b/src/packaging/version.py @@ -452,7 +452,6 @@ def micro(self) -> int: def _parse_letter_version( letter: Optional[str], number: Union[str, bytes, SupportsInt, None] ) -> Optional[Tuple[str, int]]: - if letter: # We consider there to be an implicit 0 in a pre-release if there is # not a numeral associated with it. @@ -508,7 +507,6 @@ def _cmpkey( dev: Optional[Tuple[str, int]], local: Optional[LocalType], ) -> CmpKey: - # When we compare a release version, we want to compare it with all of the # trailing zeros removed. So we'll use a reverse the list, drop all the now # leading zeros until we come to something non zero, then take the rest diff --git a/tests/test_specifiers.py b/tests/test_specifiers.py index ebcd9d98..8288c0ea 100644 --- a/tests/test_specifiers.py +++ b/tests/test_specifiers.py @@ -236,9 +236,8 @@ def test_specifiers_hash(self, specifier): @pytest.mark.parametrize( ("left", "right", "op"), itertools.chain( - * # Verify that the equal (==) operator works correctly - [[(x, x, operator.eq) for x in SPECIFIERS]] + *[[(x, x, operator.eq) for x in SPECIFIERS]] + # Verify that the not equal (!=) operator works correctly [ @@ -261,9 +260,8 @@ def test_comparison_canonicalizes(self, left, right): @pytest.mark.parametrize( ("left", "right", "op"), itertools.chain( - * # Verify that the equal (==) operator works correctly - [[(x, x, operator.ne) for x in SPECIFIERS]] + *[[(x, x, operator.ne) for x in SPECIFIERS]] + # Verify that the not equal (!=) operator works correctly [ @@ -816,9 +814,8 @@ def test_specifiers_combine_not_implemented(self): @pytest.mark.parametrize( ("left", "right", "op"), itertools.chain( - * # Verify that the equal (==) operator works correctly - [[(x, x, operator.eq) for x in SPECIFIERS]] + *[[(x, x, operator.eq) for x in SPECIFIERS]] + # Verify that the not equal (!=) operator works correctly [ @@ -837,9 +834,8 @@ def test_comparison_true(self, left, right, op): @pytest.mark.parametrize( ("left", "right", "op"), itertools.chain( - * # Verify that the equal (==) operator works correctly - [[(x, x, operator.ne) for x in SPECIFIERS]] + *[[(x, x, operator.ne) for x in SPECIFIERS]] + # Verify that the not equal (!=) operator works correctly [ diff --git a/tests/test_version.py b/tests/test_version.py index 8004c0cc..7d571d74 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -668,9 +668,8 @@ def test_version_is_postrelease(self, version, expected): # Below we'll generate every possible combination of VERSIONS that # should be True for the given operator itertools.chain( - * # Verify that the less than (<) operator works correctly - [ + *[ [(x, y, operator.lt) for y in VERSIONS[i + 1 :]] for i, x in enumerate(VERSIONS) ] @@ -711,9 +710,8 @@ def test_comparison_true(self, left, right, op): # Below we'll generate every possible combination of VERSIONS that # should be False for the given operator itertools.chain( - * # Verify that the less than (<) operator works correctly - [ + *[ [(x, y, operator.lt) for y in VERSIONS[: i + 1]] for i, x in enumerate(VERSIONS) ]