Skip to content

Commit

Permalink
Run ruff formatter on existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Jan 8, 2024
1 parent 2b18266 commit 7eb2fda
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/packaging/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/packaging/specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/packaging/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions tests/test_specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand All @@ -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
[
Expand Down Expand Up @@ -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
[
Expand All @@ -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
[
Expand Down
6 changes: 2 additions & 4 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
Expand Down Expand Up @@ -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)
]
Expand Down

0 comments on commit 7eb2fda

Please sign in to comment.