From 50e72f7235287640453adea9da7ac076027833a1 Mon Sep 17 00:00:00 2001 From: Laetitia Getti Date: Thu, 30 Mar 2023 16:35:52 +0200 Subject: [PATCH] install pytest-isort and isort and sort files --- la_chariotte/order/admin.py | 2 +- la_chariotte/order/models.py | 1 - la_chariotte/order/tests/test_models.py | 1 + la_chariotte/order/tests/test_views.py | 2 +- la_chariotte/order/views.py | 2 +- la_chariotte/urls.py | 2 +- pyproject.toml | 5 +++++ readMe.md | 7 ++++++- 8 files changed, 16 insertions(+), 6 deletions(-) diff --git a/la_chariotte/order/admin.py b/la_chariotte/order/admin.py index 0d4d29e..09e2a24 100644 --- a/la_chariotte/order/admin.py +++ b/la_chariotte/order/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Grouped_order, Order, Item, OrderedItem +from .models import Grouped_order, Item, Order, OrderedItem admin.site.register(Grouped_order) admin.site.register(Order) diff --git a/la_chariotte/order/models.py b/la_chariotte/order/models.py index 07051cb..c936bf6 100644 --- a/la_chariotte/order/models.py +++ b/la_chariotte/order/models.py @@ -1,5 +1,4 @@ from django.db import models - from django.utils import timezone diff --git a/la_chariotte/order/tests/test_models.py b/la_chariotte/order/tests/test_models.py index 2f6d89e..374d5d2 100644 --- a/la_chariotte/order/tests/test_models.py +++ b/la_chariotte/order/tests/test_models.py @@ -1,6 +1,7 @@ import datetime from django.utils import timezone + from la_chariotte.order.models import Grouped_order diff --git a/la_chariotte/order/tests/test_views.py b/la_chariotte/order/tests/test_views.py index b3d9364..a1073ea 100644 --- a/la_chariotte/order/tests/test_views.py +++ b/la_chariotte/order/tests/test_views.py @@ -1,9 +1,9 @@ import datetime import pytest - from django.urls import reverse from django.utils import timezone + from la_chariotte.order.models import Grouped_order pytestmark = pytest.mark.django_db diff --git a/la_chariotte/order/views.py b/la_chariotte/order/views.py index 8ed7154..7872019 100644 --- a/la_chariotte/order/views.py +++ b/la_chariotte/order/views.py @@ -1,5 +1,5 @@ -from django.shortcuts import render, get_object_or_404 from django.http import HttpResponseRedirect +from django.shortcuts import get_object_or_404, render from django.urls import reverse from django.utils import timezone from django.views import generic diff --git a/la_chariotte/urls.py b/la_chariotte/urls.py index 6bea7b4..cdef8bf 100644 --- a/la_chariotte/urls.py +++ b/la_chariotte/urls.py @@ -14,7 +14,7 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), diff --git a/pyproject.toml b/pyproject.toml index a8c7d06..34ac446 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,11 @@ license = {file = "LICENSE"} [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "la_chariotte.settings" +addopts = "--isort" +isort_ignore = ["*migrations/*.py"] + +[tool.isort] +skip_glob = ["*migrations/*.py"] [tool.black] line-length = 88 diff --git a/readMe.md b/readMe.md index b41147b..7d49e43 100644 --- a/readMe.md +++ b/readMe.md @@ -10,13 +10,18 @@ Lancer les tests avec pytest : pytest ``` +Si il y a des erreurs ISORT, on peut lancer isort pour trier les fichiers : +```bash +isort . +``` + Vérifier le formatage des fichers avec flake8 : ```bash flake8 ``` -Si l'erreur `BLK100 Blakck would make changes.` apparait, c'est utile de lancer black pour formater les fichiers : +Si l'erreur `BLK100 Blakck would make changes.` apparait, on peut lancer black pour formater les fichiers : ```bash black .