Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd benefit from having ruff-format here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of black?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I forgot that we'd need to remove that too.

Yes, I think we should use ruff instead of black, but that can wait for another PR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #297


- 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