Skip to content

Commit 2065a4f

Browse files
Secrusradoering
authored andcommitted
Migrate flake8 to ruff
1 parent e81166e commit 2065a4f

File tree

22 files changed

+89
-99
lines changed

22 files changed

+89
-99
lines changed

.flake8

Lines changed: 0 additions & 28 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,6 @@ repos:
3232
- id: python-use-type-annotations
3333
- id: python-check-blanket-noqa
3434

35-
- repo: https://github.com/asottile/yesqa
36-
rev: v1.4.0
37-
hooks:
38-
- id: yesqa
39-
additional_dependencies: &flake8_deps
40-
- flake8-annotations==3.0.0
41-
- flake8-broken-line==0.6.0
42-
- flake8-bugbear==23.2.13
43-
- flake8-comprehensions==3.10.1
44-
- flake8-eradicate==1.4.0
45-
- flake8-quotes==3.3.2
46-
- flake8-simplify==0.19.3
47-
- flake8-tidy-imports==4.8.0
48-
- flake8-type-checking==2.3.0
49-
- flake8-typing-imports==1.14.0
50-
- flake8-use-fstring==1.4
51-
- pep8-naming==0.13.3
52-
5335
- repo: https://github.com/asottile/pyupgrade
5436
rev: v3.3.1
5537
hooks:
@@ -79,8 +61,7 @@ repos:
7961
hooks:
8062
- id: black
8163

82-
- repo: https://github.com/pycqa/flake8
83-
rev: 5.0.4
64+
- repo: https://github.com/charliermarsh/ruff-pre-commit
65+
rev: v0.0.262
8466
hooks:
85-
- id: flake8
86-
additional_dependencies: *flake8_deps
67+
- id: ruff

pyproject.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,40 @@ tomli-w = "^1.0.0"
5656
types-jsonschema = ">=4.4.4"
5757
types-setuptools = ">=57.4.14"
5858

59+
60+
[tool.ruff]
61+
fix = true
62+
unfixable = [
63+
"ERA", # do not autoremove commented out code
64+
]
65+
target-version = "py37"
66+
line-length = 88
67+
extend-select = [
68+
"B", # flake8-bugbear
69+
"C4", # flake8-comprehensions
70+
"ERA", # flake8-eradicate/eradicate
71+
"PIE", # flake8-pie
72+
"SIM", # flake8-simplify
73+
"TID", # flake8-tidy-imports
74+
"TCH", # flake8-type-checking
75+
"N", # pep8-naming
76+
"RUF", # ruff checks
77+
]
78+
ignore = [
79+
"B904", # use 'raise ... from err'
80+
"B905", # use explicit 'strict=' parameter with 'zip()'
81+
"N818" # Exception name should be named with an Error suffix
82+
]
83+
extend-exclude = [
84+
"src/poetry/core/_vendor/*",
85+
"tests/fixtures/*",
86+
"tests/**/fixtures/*"
87+
]
88+
89+
[tool.ruff.flake8-tidy-imports]
90+
ban-relative-imports = "all"
91+
92+
5993
[tool.black]
6094
line-length = 88
6195
preview = true

src/poetry/core/constraints/version/version_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def difference(self, other: VersionConstraint) -> VersionConstraint:
328328
if not ranges:
329329
return current
330330

331-
return VersionUnion.of(*(ranges + [current]))
331+
return VersionUnion.of(*([*ranges, current]))
332332

333333
raise ValueError(f"Unknown VersionConstraint type {other}.")
334334

src/poetry/core/json/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def validate_object(obj: dict[str, Any], schema_name: str) -> list[str]:
2525
from jsonschema import Draft7Validator
2626

2727
validator = Draft7Validator(schema)
28-
validation_errors = sorted(validator.iter_errors(obj), key=lambda e: e.path) # type: ignore[no-any-return]
28+
validation_errors = sorted(validator.iter_errors(obj), key=lambda e: e.path) # type: ignore[no-any-return] # noqa: E501
2929

3030
errors = []
3131

src/poetry/core/masonry/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ def get_requires_for_build_wheel(
2323
Returns an additional list of requirements for building, as PEP508 strings,
2424
above and beyond those specified in the pyproject.toml file.
2525
26-
This implementation is optional. At the moment it only returns an empty list, which would be the same as if
27-
not define. So this is just for completeness for future implementation.
26+
This implementation is optional. At the moment it only returns an empty list,
27+
which would be the same as if not define. So this is just for completeness
28+
for future implementation.
2829
"""
2930

3031
return []

src/poetry/core/masonry/builders/builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
from poetry.core.poetry import Poetry
1515

1616

17-
AUTHOR_REGEX = re.compile(r"(?u)^(?P<name>[- .,\w\d'’\"()]+) <(?P<email>.+?)>$")
17+
AUTHOR_REGEX = re.compile(
18+
r"(?u)^(?P<name>[- .,\w\d'’\"()]+) <(?P<email>.+?)>$" # noqa: RUF001
19+
)
1820

1921
METADATA_BASE = """\
2022
Metadata-Version: 2.1

src/poetry/core/masonry/builders/sdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def find_nearest_pkg(rel_path: str) -> tuple[str, str]:
289289
if is_subpkg:
290290
subpkg_paths.add(from_top_level)
291291
parts = from_top_level.split(os.sep)
292-
packages.append(".".join([pkg_name] + parts))
292+
packages.append(".".join([pkg_name, *parts]))
293293
else:
294294
pkg, from_nearest_pkg = find_nearest_pkg(from_top_level)
295295

src/poetry/core/masonry/utils/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def escape_version(version: str) -> str:
4848
def escape_name(name: str) -> str:
4949
"""
5050
Escaped wheel name as specified in https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode.
51-
This function should only be used for the generation of artifact names, and not to normalize or filter existing artifact names.
51+
This function should only be used for the generation of artifact names,
52+
and not to normalize or filter existing artifact names.
5253
"""
5354
warnings.warn(
5455
(

src/poetry/core/packages/package.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434

3535
T = TypeVar("T", bound="Package")
3636

37-
AUTHOR_REGEX = re.compile(r"(?u)^(?P<name>[- .,\w\d'’\"():&]+)(?: <(?P<email>.+?)>)?$")
37+
AUTHOR_REGEX = re.compile(
38+
r"(?u)^(?P<name>[- .,\w\d'’\"():&]+)(?: <(?P<email>.+?)>)?$" # noqa: RUF001
39+
)
3840

3941

4042
class Package(PackageSpecification):

0 commit comments

Comments
 (0)