Skip to content

Commit

Permalink
Merge pull request #236 from classy-python/switch-to-ruff
Browse files Browse the repository at this point in the history
Switch to ruff
  • Loading branch information
meshy authored Jun 2, 2024
2 parents d80847b + 7398948 commit be2107c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
12 changes: 0 additions & 12 deletions .flake8

This file was deleted.

11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cbv/importer/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 2 additions & 6 deletions tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit be2107c

Please sign in to comment.