Skip to content

Commit

Permalink
Setup and run ruff formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
etchegom committed Feb 25, 2025
1 parent c41ad2b commit 9cc9dab
Show file tree
Hide file tree
Showing 97 changed files with 41 additions and 190 deletions.
11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ repos:
- id: trailing-whitespace
exclude_types: [sql]

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.0"
rev: v0.9.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.22.1"
Expand All @@ -25,8 +21,7 @@ repos:
args: [--target-version, "5.0"]

- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.5.30
rev: 0.6.0
hooks:
- id: uv-lock
- id: uv-export
1 change: 1 addition & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
5 changes: 4 additions & 1 deletion notebooks/dsrc_doc/ComponentTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ def _load_asset(rel_file_path):
)

context = Context(
{"projects": projects.order_by("-created_on")[:5], "csscore": csscore.data}
{
"projects": projects.order_by("-created_on")[:5],
"csscore": csscore.data,
}
)

HTML(template.render(context))
Expand Down
17 changes: 12 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
name = "recoco"
dynamic = ["version"]

authors = [{name = "Recoco Dev Team"}]
authors = [{ name = "Recoco Dev Team" }]
maintainers = [
{name = "Guillaume Libersat", email = "[email protected]"}
{ name = "Guillaume Libersat", email = "[email protected]" },
]
license = {name = "AGPL-v3", file="LICENSE"}
license = { name = "AGPL-v3", file = "LICENSE" }

description = "Recommandations Collaboratives"
readme = "README.md"
Expand Down Expand Up @@ -82,7 +82,7 @@ Repository = "https://github.com/betagouv/recommandations-collaboratives/"
packages = ["recoco"]

[tool.setuptools.dynamic]
version = {attr = "recoco.__version__"}
version = { attr = "recoco.__version__" }

[build-system]
requires = ["setuptools"]
Expand Down Expand Up @@ -194,7 +194,6 @@ django-webhook = { git = "https://github.com/etchegom/django-webhook.git", rev =

[dependency-groups]
dev = [
"black>=25.1.0",
"coverage==7.4.1",
"django-coverage-plugin>=3.1.0",
"django-debug-toolbar==4.3.0",
Expand Down Expand Up @@ -231,3 +230,11 @@ dev = [
"sphinxcontrib-django>=2.5",
"sphinxcontrib-django-urls>=0.3",
]


[tool.ruff]
line-length = 88

[tool.ruff.format]
skip-magic-trailing-comma = false
exclude = ["*.ipynb", "fabfile.py", "notebooks/*", "sql/*", "frontend_tests/*", "docs/*", "node_modules/*"]
2 changes: 1 addition & 1 deletion recoco/apps/addressbook/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OrganizationGroupAdmin(admin.ModelAdmin):

@admin.register(models.Organization)
class OrganizationAdmin(admin.ModelAdmin):
search_fields = ["name" "group__name"]
search_fields = ["name", "group__name"]
list_display = ["name"]
ordering = ["name"]
list_filter = ["sites", "group"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("addressbook", "0009_alter_organization_departments"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("addressbook", "0010_organizationgroup_organization_group"),
]
Expand Down
6 changes: 3 additions & 3 deletions recoco/apps/addressbook/tests/test_rest_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ def test_contact_search_filter(
reverse("api-addressbook-contact-list"), {"search": search_terms}
)
assert response.status_code == 200
assert [
contact["id"] for contact in response.data["results"]
] == expected_result, f"failure for search terms: {search_terms}"
assert [contact["id"] for contact in response.data["results"]] == expected_result, (
f"failure for search terms: {search_terms}"
)


@pytest.mark.parametrize(
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/addressbook/tests/test_views_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_organization_list_not_available_for_non_staff(client):

@pytest.mark.django_db
def test_create_existing_organization_and_redirect(current_site, client):

organization = Recipe(
Organization, sites=[current_site], name="my organization"
).make()
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/addressbook/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created : 2021-07-16 16:22:25 CEST
"""


from django.urls import path

from . import views
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created: 2022-01-24 22:39:27 CEST
"""


import logging

from django.conf import settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created: 2022-01-24 22:39:27 CEST
"""


import json

from django.core.management.base import BaseCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("communication", "0012_alter_emailtemplate_site"),
]
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/crm/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created : 2022-07-19 17:27:25 CEST
"""


from django.urls import path

from . import views
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("demarches_simplifiees", "0001_initial"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [
("sites", "0002_alter_domain_unique"),
("demarches_simplifiees", "0002_remove_dsresource_type"),
Expand Down
2 changes: 1 addition & 1 deletion recoco/apps/demarches_simplifiees/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def ds_schema_sample():
"description": "Ce formulaire est destiné aux collectivités de Moselle qui souhaitent déposer une demande de subvention au titre de la DETR ou de la DSIL en 2024. Votre demande sera automatiquement orientée vers la sous-préfecture compétente.\r\n\r\nLa date limite de dépôt des dossiers est fixée au 30 novembre 2023.\r\n\r\nDans le cadre de l'instruction des demandes, les projets sont orientés par les sous-préfets en lien avec la préfecture vers la dotation la plus adaptée (DETR ou DSIL).\r\n\r\nPour l'éligibilité des opérations, il convient de se référer à l’appel à projets 2024 commun à la DETR et à la DSIL, disponible à l'adresse suivante : https://www.moselle.gouv.fr/Actions-de-l-Etat/Collectivites-controle-de-legalite-et-finances-locales/Subventions\r\n\r\n",
"required": False,
"collapsibleExplanationEnabled": True,
"collapsibleExplanationText": "\r\nPour constituer votre dossier, les sections suivantes sont à compléter :\r\n\r\n-Informations sur le porteur de projet\r\n-Présentation de l'opération\r\n-Plan de financement prévisionnel\r\n-Finalisation du dossier\r\n\r\n\r\n\u003Cbr /\u003E\r\n\r\nVotre dossier est enregistré automatiquement après chaque modification. Vous pouvez à tout moment fermer la fenêtre et reprendre plus tard là où vous en étiez.",
"collapsibleExplanationText": "\r\nPour constituer votre dossier, les sections suivantes sont à compléter :\r\n\r\n-Informations sur le porteur de projet\r\n-Présentation de l'opération\r\n-Plan de financement prévisionnel\r\n-Finalisation du dossier\r\n\r\n\r\n\u003cbr /\u003e\r\n\r\nVotre dossier est enregistré automatiquement après chaque modification. Vous pouvez à tout moment fermer la fenêtre et reprendre plus tard là où vous en étiez.",
},
{
"__typename": "YesNoChampDescriptor",
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/demarches_simplifiees/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def test_trigger_load_ds_resource_schema(settings, autoload_enabled, expected_ca
with patch(
"recoco.apps.demarches_simplifiees.signals.load_ds_resource_schema"
) as mock_load_ds_resource_schema:

ds_resource = baker.make(DSResource)
ds_resource.schema = {"number": 123}
ds_resource.save()
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/dsrc/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created : 2024-03-02 01:13:25 CEST
"""


from django.urls import path

from . import views
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/feature_flag/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("geomatics", "0004_alter_department_region"),
]
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/geomatics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created: 2021-07-12 12:05:28 CEST
"""


from django.db import models


Expand Down
1 change: 0 additions & 1 deletion recoco/apps/hitcount/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("hitcount", "0001_initial"),
Expand Down
6 changes: 3 additions & 3 deletions recoco/apps/hitcount/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def test_hit_view():
)
assert response.status_code == 200
assert HitCount.objects.count() == 1
assert (
hitcount.hits.count() == 2
), "no hit should be registered when user is hijacked"
assert hitcount.hits.count() == 2, (
"no hit should be registered when user is hijacked"
)
6 changes: 3 additions & 3 deletions recoco/apps/home/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class UVSignupForm(SignupForm):
def __init__(self, *args, **kwargs):
super(UVSignupForm, self).__init__(*args, **kwargs)

self.fields["password1"].label = (
"Définissez votre mot de passe (8 caractères minimum)"
)
self.fields[
"password1"
].label = "Définissez votre mot de passe (8 caractères minimum)"
self.fields["password1"].widget = forms.PasswordInput(
attrs={"class": "fr-input fr-mt-2v fr-mb-4v"}
)
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/home/management/commands/create_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def handle(self, *args, **options):
email_logo = options["email_logo"]

try:

admin_user = None
if options["admin_user"]:
admin_user = User.objects.get(username=options["admin_user"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("survey", "0033_alter_session_project"),
("home", "0023_auto_20240206_1216"),
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/home/migrations/0026_merge_20240422_0744.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("home", "0024_siteconfiguration_onboarding_questions"),
("home", "0025_siteconfiguration_legal_address"),
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/home/migrations/0026_merge_20240422_1101.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("home", "0024_siteconfiguration_onboarding_questions"),
("home", "0025_siteconfiguration_legal_address"),
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/home/migrations/0027_merge_20240423_1117.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("home", "0026_merge_20240422_0744"),
("home", "0026_merge_20240422_1101"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("home", "0029_siteconfiguration_description"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("taggit", "0005_auto_20220424_2025"),
("home", "0030_siteconfiguration_logo_large_and_more"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("taggit", "0005_auto_20220424_2025"),
("home", "0031_alter_siteconfiguration_contact_form_recipient_and_more"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("home", "0032_siteconfiguration_accept_handover_and_more"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("home", "0033_siteconfiguration_main_topic"),
]
Expand Down
2 changes: 0 additions & 2 deletions recoco/apps/home/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class UserNotificationsMarkOneAsRead(APIView):

permission_classes = [IsAuthenticated]

def patch(self, request, pk):
Expand All @@ -33,7 +32,6 @@ def patch(self, request, pk):


class UserNotificationsMarkAllAsRead(APIView):

permission_classes = [IsAuthenticated]

def patch(self, request, *args, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion recoco/apps/home/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
created: 2022-05-16 17:44:55 CET
"""


from django.contrib.auth import models as auth_models
from django.contrib.sites import models as sites_models
from rest_framework import serializers
Expand Down
Loading

0 comments on commit 9cc9dab

Please sign in to comment.