Skip to content

Commit cb8fd38

Browse files
pyupgrade/black/isort/flake8 → ruff (#769)
1 parent e8002b1 commit cb8fd38

7 files changed

+49
-39
lines changed

.flake8

-3
This file was deleted.

.pre-commit-config.yaml

+5-22
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,9 @@ repos:
1515
args: []
1616
additional_dependencies: [pyparsing, nox]
1717

18-
- repo: https://github.com/asottile/pyupgrade
19-
rev: v3.3.1
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.1.11
2020
hooks:
21-
- id: pyupgrade
22-
args: [--py37-plus]
23-
24-
- repo: https://github.com/psf/black
25-
rev: 22.12.0
26-
hooks:
27-
- id: black
28-
29-
- repo: https://github.com/PyCQA/isort
30-
rev: 5.12.0
31-
hooks:
32-
- id: isort
33-
34-
- repo: https://github.com/PyCQA/flake8
35-
rev: "6.0.0"
36-
hooks:
37-
- id: flake8
38-
additional_dependencies: ["pep8-naming"]
39-
# Ignore all format-related checks as Black takes care of those.
40-
args: ["--ignore", "E2,W5", "--select", "E,W,F,N"]
21+
- id: ruff
22+
args: [ --fix ]
23+
- id: ruff-format

pyproject.toml

+39-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,42 @@ module = ["_manylinux"]
5757
ignore_missing_imports = true
5858

5959

60-
[tool.isort]
61-
profile = "black"
62-
combine_as_imports = true
60+
[tool.ruff]
61+
src = ["src"]
62+
63+
[tool.ruff.lint]
64+
extend-select = [
65+
"B",
66+
"E",
67+
"F",
68+
"I",
69+
"N",
70+
"UP",
71+
"W"
72+
]
73+
ignore = [
74+
"B009",
75+
"B015",
76+
"B018",
77+
"B027",
78+
"B028",
79+
"B904",
80+
"N818",
81+
"UP032",
82+
"UP030",
83+
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
84+
"W191",
85+
"E111",
86+
"E114",
87+
"E117",
88+
"D206",
89+
"D300",
90+
"Q000",
91+
"Q001",
92+
"Q002",
93+
"Q003",
94+
"COM812",
95+
"COM819",
96+
"ISC001",
97+
"ISC002",
98+
]

src/packaging/markers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
Op,
1515
Value,
1616
Variable,
17+
)
18+
from ._parser import (
1719
parse_marker as _parse_marker,
1820
)
1921
from ._tokenizer import ParserSyntaxError
@@ -69,7 +71,6 @@ def _normalize_extra_values(results: Any) -> Any:
6971
def _format_marker(
7072
marker: Union[List[str], MarkerAtom, str], first: Optional[bool] = True
7173
) -> str:
72-
7374
assert isinstance(marker, (list, tuple, str))
7475

7576
# Sometimes we have a structure like [[...]] which is a single item list

src/packaging/metadata.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
cast,
1919
)
2020

21-
from . import requirements, specifiers, utils, version as version_module
21+
from . import requirements, specifiers, utils
22+
from . import version as version_module
2223

2324
T = typing.TypeVar("T")
2425
if sys.version_info[:2] >= (3, 8): # pragma: no cover
@@ -44,7 +45,7 @@ def __init_subclass__(*_args, **_kwargs):
4445
ExceptionGroup
4546
except NameError: # pragma: no cover
4647

47-
class ExceptionGroup(Exception): # noqa: N818
48+
class ExceptionGroup(Exception):
4849
"""A minimal implementation of :external:exc:`ExceptionGroup` from Python 3.11.
4950
5051
If :external:exc:`ExceptionGroup` is already defined by Python itself,

src/packaging/specifiers.py

-6
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ def _get_operator(self, op: str) -> CallableOperator:
364364
return operator_callable
365365

366366
def _compare_compatible(self, prospective: Version, spec: str) -> bool:
367-
368367
# Compatible releases have an equivalent combination of >= and ==. That
369368
# is that ~=2.2 is equivalent to >=2.2,==2.*. This allows us to
370369
# implement this in terms of the other specifiers instead of
@@ -385,7 +384,6 @@ def _compare_compatible(self, prospective: Version, spec: str) -> bool:
385384
)
386385

387386
def _compare_equal(self, prospective: Version, spec: str) -> bool:
388-
389387
# We need special logic to handle prefix matching
390388
if spec.endswith(".*"):
391389
# In the case of prefix matching we want to ignore local segment.
@@ -429,21 +427,18 @@ def _compare_not_equal(self, prospective: Version, spec: str) -> bool:
429427
return not self._compare_equal(prospective, spec)
430428

431429
def _compare_less_than_equal(self, prospective: Version, spec: str) -> bool:
432-
433430
# NB: Local version identifiers are NOT permitted in the version
434431
# specifier, so local version labels can be universally removed from
435432
# the prospective version.
436433
return Version(prospective.public) <= Version(spec)
437434

438435
def _compare_greater_than_equal(self, prospective: Version, spec: str) -> bool:
439-
440436
# NB: Local version identifiers are NOT permitted in the version
441437
# specifier, so local version labels can be universally removed from
442438
# the prospective version.
443439
return Version(prospective.public) >= Version(spec)
444440

445441
def _compare_less_than(self, prospective: Version, spec_str: str) -> bool:
446-
447442
# Convert our spec to a Version instance, since we'll want to work with
448443
# it as a version.
449444
spec = Version(spec_str)
@@ -468,7 +463,6 @@ def _compare_less_than(self, prospective: Version, spec_str: str) -> bool:
468463
return True
469464

470465
def _compare_greater_than(self, prospective: Version, spec_str: str) -> bool:
471-
472466
# Convert our spec to a Version instance, since we'll want to work with
473467
# it as a version.
474468
spec = Version(spec_str)

src/packaging/version.py

-2
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ def micro(self) -> int:
452452
def _parse_letter_version(
453453
letter: Optional[str], number: Union[str, bytes, SupportsInt, None]
454454
) -> Optional[Tuple[str, int]]:
455-
456455
if letter:
457456
# We consider there to be an implicit 0 in a pre-release if there is
458457
# not a numeral associated with it.
@@ -508,7 +507,6 @@ def _cmpkey(
508507
dev: Optional[Tuple[str, int]],
509508
local: Optional[LocalType],
510509
) -> CmpKey:
511-
512510
# When we compare a release version, we want to compare it with all of the
513511
# trailing zeros removed. So we'll use a reverse the list, drop all the now
514512
# leading zeros until we come to something non zero, then take the rest

0 commit comments

Comments
 (0)