Skip to content

Commit

Permalink
Ruff + django-extensions in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
rik committed Mar 2, 2025
1 parent 7023760 commit 9b2a43f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions django/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from enum import StrEnum, auto
from itertools import groupby
from json import load
from operator import attrgetter, itemgetter
from operator import attrgetter
from typing import Self, TypedDict

from django.conf import settings
Expand Down Expand Up @@ -216,7 +216,7 @@ def with_events(self) -> Self:


class ProcedureManager(models.Manager):
def get_queryset(self):
def get_queryset(self) -> ProcedureQuerySet:
return super().get_queryset().with_events()


Expand Down Expand Up @@ -401,7 +401,7 @@ class CommuneProcedure(models.Model):
Procedure, models.DO_NOTHING, related_name="perimetre"
)
# opposable = models.BooleanField()
departement = models.CharField(blank=True, null=True)
departement = models.CharField(blank=True, null=True) # noqa: DJ001

objects = CommuneProcedureQuerySet.as_manager()

Expand All @@ -416,7 +416,7 @@ def __str__(self) -> str:
except KeyError:
return f"{self.collectivite_code} - {self.procedure}"

def _opposable(self, all_perims) -> bool:
def _opposable(self, all_perims: list[Self]) -> bool:
procedures_opposables = sorted(
(
perim.procedure
Expand All @@ -437,7 +437,7 @@ def _opposable(self, all_perims) -> bool:
for p in procedures_opposables:
if p.is_principale:
logging.warning(
f"{p.id=!s} {p.date_approbation=} {p.created_at=!s}"
f"{p.id=!s} {p.date_approbation=} {p.created_at=!s}" # noqa: G004
)
if not procedures_opposables:
return False
Expand Down
2 changes: 1 addition & 1 deletion django/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
path("_admin/", admin.site.urls),
path("api/perimetres", views.perimetres),
path("__reload__/", include("django_browser_reload.urls")),
# re_path(r"(?P<path>.*)", ProxyView.as_view(upstream=settings.UPSTREAM_NUXT)),
re_path(r"(?P<path>.*)", ProxyView.as_view(upstream=settings.UPSTREAM_NUXT)),
*debug_toolbar_urls(),
]
6 changes: 1 addition & 5 deletions django/core/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import logging
from csv import DictWriter
from operator import attrgetter

from django.db.models import Prefetch
from django.http import HttpRequest, HttpResponse

from core.models import CommuneProcedure, Procedure, communes
from core.models import CommuneProcedure


def _format_perimetre(perimetre: dict) -> dict:
Expand Down Expand Up @@ -41,7 +38,6 @@ def perimetres(request: HttpRequest) -> HttpResponse:
csv_writer.writeheader()
for perimetre in perimetres[: int(request.GET.get("limit", -1))]: # .iterator()
a = {field: getattr(perimetre, field) for field in csv_writer.fieldnames}
# a["opposable"] = perimetre.opposable
csv_writer.writerow(a)

return response
4 changes: 3 additions & 1 deletion django/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies = [
"django",
"django-browser-reload",
"django-environ",
"django-extensions",
"django-revproxy",
"gunicorn[gevent]",
"psycopg[binary]",
Expand All @@ -17,7 +18,6 @@ dependencies = [
[dependency-groups]
dev = [
"django-debug-toolbar",
"django-extensions",
"honcho",
"polars",
"ptpython",
Expand All @@ -36,6 +36,8 @@ ignore = [
"COM812", # Missing trailing comma, conflicts with formatter
"D10", # Missing docstring
"E501", # Line too long
"TD", # Todos
"ERA001", # Commented out code
]
[tool.ruff.lint.per-file-ignores]
"**/tests/**.py" = [
Expand Down
2 changes: 1 addition & 1 deletion django/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv export --hashes --output-file requirements-dev.txt
# uv export --output-file requirements-dev.txt
appdirs==1.4.4 \
--hash=sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41 \
--hash=sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128
Expand Down
3 changes: 3 additions & 0 deletions django/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ django-browser-reload==1.18.0 \
django-environ==0.12.0 \
--hash=sha256:227dc891453dd5bde769c3449cf4a74b6f2ee8f7ab2361c93a07068f4179041a \
--hash=sha256:92fb346a158abda07ffe6eb23135ce92843af06ecf8753f43adf9d2366dcc0ca
django-extensions==3.2.3 \
--hash=sha256:44d27919d04e23b3f40231c4ab7af4e61ce832ef46d610cc650d53e68328410a \
--hash=sha256:9600b7562f79a92cbf1fde6403c04fee314608fefbb595502e34383ae8203401
django-revproxy==0.13.0 \
--hash=sha256:6130d52d5042624c918134369be0a825e9f7e87d15e12b739d6666e5ed1f32ef
gevent==24.11.1 \
Expand Down
4 changes: 2 additions & 2 deletions django/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b2a43f

Please sign in to comment.