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 4bf979a5..14e1efb3 100644 --- a/tests/test_specifiers.py +++ b/tests/test_specifiers.py @@ -235,9 +235,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 [ @@ -260,9 +259,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 [ @@ -815,9 +813,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 [ @@ -836,9 +833,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 2c9d339d..0fe693ef 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -667,9 +667,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) ] @@ -710,9 +709,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) ]