Skip to content

Commit be2107c

Browse files
authored
Merge pull request #236 from classy-python/switch-to-ruff
Switch to ruff
2 parents d80847b + 7398948 commit be2107c

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

.flake8

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

.pre-commit-config.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ repos:
1313
hooks:
1414
- id: black
1515

16-
- repo: https://github.com/PyCQA/flake8
17-
rev: 7.0.0
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.4.4
1818
hooks:
19-
- id: flake8
20-
21-
- repo: https://github.com/timothycrosley/isort
22-
rev: 5.13.2
23-
hooks:
24-
- id: isort
19+
- id: ruff
2520

2621
- repo: https://github.com/asottile/pyupgrade
2722
rev: v3.15.2

cbv/importer/importers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _handle_class_on_module(
111111
if inspect.getsourcefile(member) != inspect.getsourcefile(parent):
112112
return None
113113

114-
if issubclass(member, (Exception, Warning)):
114+
if issubclass(member, Exception | Warning):
115115
return None
116116

117117
yield Klass(

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,25 @@ DJANGO_SETTINGS_MODULE = "core.settings"
3838
python_files = [
3939
"test_*.py",
4040
]
41+
42+
[tool.ruff]
43+
extend-exclude = [
44+
".env",
45+
]
46+
target-version = "py310"
47+
48+
[tool.ruff.lint]
49+
extend-select = [
50+
"A", # flake8-builtins
51+
"I", # isort
52+
"INP", # flake8-no-pep420
53+
"ISC", # flake8-implicit-str-concat
54+
"UP", # pyupgrade
55+
"W", # pycodestyle warning
56+
]
57+
extend-ignore = [
58+
"E731", # allow lambda assignment
59+
]
60+
61+
[tool.ruff.lint.isort]
62+
lines-after-imports = 2

tests/factories.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Meta:
1515
model = Module
1616

1717
project_version = factory.SubFactory(ProjectVersionFactory)
18-
name = factory.Sequence("module{}".format)
18+
name = factory.Sequence(lambda n: f"module{n}")
1919

2020

2121
class KlassFactory(factory.django.DjangoModelFactory):
@@ -25,11 +25,7 @@ class Meta:
2525
module = factory.SubFactory(ModuleFactory)
2626
name = factory.Sequence("klass{}".format)
2727
line_number = 1
28-
import_path = factory.LazyAttribute(
29-
lambda a: "Django.{module}".format(
30-
module=a.module.name,
31-
)
32-
)
28+
import_path = factory.LazyAttribute(lambda a: f"Django.{a.module.name}")
3329

3430

3531
class InheritanceFactory(factory.django.DjangoModelFactory):

0 commit comments

Comments
 (0)