diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 3d7becca..00000000 --- a/.flake8 +++ /dev/null @@ -1,12 +0,0 @@ -[flake8] -exclude = .direnv, .env, .venv, venv -ignore = - # whitespace before ':' (conflicts with Black) - E203 - # line too long (probably right, but if Black let it go, Flake8 should too) - E501 - # line break before binary operator (conflicts with Black) - W503 - # multiple statements on one line (conflicts with Black) - E704 -max_line_length = 88 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ecd715e..01a5474c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,15 +13,10 @@ repos: hooks: - id: black - - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.4 hooks: - - id: flake8 - - - repo: https://github.com/timothycrosley/isort - rev: 5.13.2 - hooks: - - id: isort + - id: ruff - repo: https://github.com/asottile/pyupgrade rev: v3.15.2 diff --git a/cbv/importer/importers.py b/cbv/importer/importers.py index 9e77120f..28d69180 100644 --- a/cbv/importer/importers.py +++ b/cbv/importer/importers.py @@ -111,7 +111,7 @@ def _handle_class_on_module( if inspect.getsourcefile(member) != inspect.getsourcefile(parent): return None - if issubclass(member, (Exception, Warning)): + if issubclass(member, Exception | Warning): return None yield Klass( diff --git a/pyproject.toml b/pyproject.toml index a3a18464..ea805622 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,3 +38,25 @@ DJANGO_SETTINGS_MODULE = "core.settings" python_files = [ "test_*.py", ] + +[tool.ruff] +extend-exclude = [ + ".env", +] +target-version = "py310" + +[tool.ruff.lint] +extend-select = [ + "A", # flake8-builtins + "I", # isort + "INP", # flake8-no-pep420 + "ISC", # flake8-implicit-str-concat + "UP", # pyupgrade + "W", # pycodestyle warning +] +extend-ignore = [ + "E731", # allow lambda assignment +] + +[tool.ruff.lint.isort] +lines-after-imports = 2 diff --git a/tests/factories.py b/tests/factories.py index 22a701bf..3ac6ffac 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -15,7 +15,7 @@ class Meta: model = Module project_version = factory.SubFactory(ProjectVersionFactory) - name = factory.Sequence("module{}".format) + name = factory.Sequence(lambda n: f"module{n}") class KlassFactory(factory.django.DjangoModelFactory): @@ -25,11 +25,7 @@ class Meta: module = factory.SubFactory(ModuleFactory) name = factory.Sequence("klass{}".format) line_number = 1 - import_path = factory.LazyAttribute( - lambda a: "Django.{module}".format( - module=a.module.name, - ) - ) + import_path = factory.LazyAttribute(lambda a: f"Django.{a.module.name}") class InheritanceFactory(factory.django.DjangoModelFactory):