Skip to content

Commit 8cd21d0

Browse files
committed
Added ruff linting
1 parent aa5ec7a commit 8cd21d0

File tree

6 files changed

+38
-20
lines changed

6 files changed

+38
-20
lines changed

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ install-full: ## Install dependencies
1919

2020
lint: ## Run code linters
2121
black --check ellar_django tests
22-
isort --check ellar_django tests
23-
autoflake --remove-unused-variables --remove-unused-variables -r ellar_django tests
24-
flake8 ellar_django tests
22+
ruff check ellar_django tests
2523
mypy ellar_django
2624

2725
fmt format: ## Run code formatters
2826
black ellar_django tests
29-
isort ellar_django tests
27+
ruff check --fix ellar_django tests
3028

3129
test: ## Run tests
3230
pytest tests

ellar_django/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@command(
1616
name="django",
17-
context_settings=dict(ignore_unknown_options=True, allow_extra_args=True),
17+
context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
1818
help=HELP_MESSAGE,
1919
)
2020
def django_command_wrapper() -> None:

pyproject.toml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = [
1212
{name = "Ezeudoh Tochukwu", email = "[email protected]"},
1313
]
1414
dynamic = ["version", "description"]
15-
requires-python = ">=3.7"
15+
requires-python = ">=3.8"
1616
readme = "README.md"
1717
home-page = "https://github.com/eadwinCode/ellar-django-module"
1818
classifiers = [
@@ -62,13 +62,33 @@ test = [
6262
"pytest >= 7.1.3,<8.0.0",
6363
"pytest-django",
6464
"pytest-cov >= 2.12.0,<5.0.0",
65-
"mypy == 0.971",
66-
"flake8 >= 3.8.3,<7.0.0",
65+
"mypy == 1.4.1",
66+
"ruff ==0.0.275",
6767
"black == 22.8.0",
68-
"isort >= 5.0.6,<6.0.0",
6968
"pytest-asyncio",
7069
"autoflake",
7170
]
7271
dev = [
7372
"pre-commit"
7473
]
74+
75+
[tool.ruff]
76+
select = [
77+
"E", # pycodestyle errors
78+
"W", # pycodestyle warnings
79+
"F", # pyflakes
80+
"I", # isort
81+
"C", # flake8-comprehensions
82+
"B", # flake8-bugbear
83+
]
84+
ignore = [
85+
"E501", # line too long, handled by black
86+
"B008", # do not perform function calls in argument defaults
87+
"C901", # too complex
88+
]
89+
90+
[tool.ruff.per-file-ignores]
91+
"__init__.py" = ["F401"]
92+
93+
[tool.ruff.isort]
94+
known-third-party = ["ellar", "Django"]

tests/example_app/root_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class ApplicationModule(ModuleBase):
2424
@exception_handler(404)
2525
def exception_404_handler(cls, ctx: IExecutionContext, exc: Exception) -> Response:
26-
return JSONResponse(dict(detail="Resource not found."))
26+
return JSONResponse({"detail": "Resource not found."})
2727

2828
def register_services(self, container: Container) -> None:
2929
from .services.event_repository import EventRepository

tests/example_app/services/event_repository.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
@injectable
1111
class EventRepository(IEventRepository):
12-
_dummy_data = dict(
13-
title="TestEvent1Title",
14-
start_date=str(datetime.now().date()),
15-
end_date=str((datetime.now() + timedelta(days=5)).date()),
16-
)
12+
_dummy_data = {
13+
"title": "TestEvent1Title",
14+
"start_date": str(datetime.now().date()),
15+
"end_date": str((datetime.now() + timedelta(days=5)).date()),
16+
}
1717

1818
def create_dummy_events(self):
1919
for i in range(3):

tests/test_event_controller.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class TestEventController:
1111
def test_create_event_works(self, client):
1212
response = client.post(
1313
"/event/",
14-
json=dict(
15-
title="TestEvent1Title",
16-
start_date=str(datetime.now().date()),
17-
end_date=str((datetime.now() + timedelta(days=5)).date()),
18-
),
14+
json={
15+
"title": "TestEvent1Title",
16+
"start_date": str(datetime.now().date()),
17+
"end_date": str((datetime.now() + timedelta(days=5)).date()),
18+
},
1919
)
2020
assert response.status_code == 201
2121
data = response.json()

0 commit comments

Comments
 (0)