Test isort flake8-isort & fix issues

fixes #2123
This commit is contained in:
Bruno Alla 2020-03-03 19:53:15 +00:00
parent 52dc302c93
commit fab6b8724a
15 changed files with 19 additions and 14 deletions

View File

@ -1,4 +1,4 @@
[pytest]
addopts = -x --tb=short
addopts = --tb=short
python_paths = .
norecursedirs = .tox .git */migrations/* */static/* docs venv */{{cookiecutter.project_slug}}/*

View File

@ -6,6 +6,7 @@ binaryornot==0.4.4
# ------------------------------------------------------------------------------
black==19.10b0
flake8==3.7.9
flake8-isort==2.8.0
# Testing
# ------------------------------------------------------------------------------

View File

@ -13,8 +13,8 @@ indent_style = space
indent_size = 4
[*.py]
line_length = 120
known_first_party = {{ cookiecutter.project_slug }}
line_length = 88
known_first_party = {{cookiecutter.project_slug}},config
multi_line_output = 3
default_section = THIRDPARTY
recursive = true

View File

@ -1,5 +1,6 @@
from rest_framework.routers import DefaultRouter, SimpleRouter
from django.conf import settings
from rest_framework.routers import DefaultRouter, SimpleRouter
from {{ cookiecutter.project_slug }}.users.api.views import UserViewSet
if settings.DEBUG:

View File

@ -1,4 +1,5 @@
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.

View File

@ -1,3 +1,4 @@
"""isort:skip_file"""
{% if cookiecutter.use_sentry == 'y' -%}
import logging

View File

@ -1,10 +1,10 @@
from django.conf import settings
from django.urls import include, path
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView
from django.urls import include, path
from django.views import defaults as default_views
{% if cookiecutter.use_drf == 'y' -%}
from django.views.generic import TemplateView
{%- if cookiecutter.use_drf == 'y' %}
from rest_framework.authtoken.views import obtain_auth_token
{%- endif %}

View File

@ -19,6 +19,7 @@ pytest-sugar==0.9.2 # https://github.com/Frozenball/pytest-sugar
# Code quality
# ------------------------------------------------------------------------------
flake8==3.7.9 # https://github.com/PyCQA/flake8
flake8-isort==2.8.0 # https://github.com/gforcada/flake8-isort
coverage==5.0.3 # https://github.com/nedbat/coveragepy
black==19.10b0 # https://github.com/ambv/black
pylint-django==2.0.14 # https://github.com/PyCQA/pylint-django

View File

@ -1,4 +1,5 @@
from rest_framework import serializers
from {{ cookiecutter.project_slug }}.users.models import User

View File

@ -1,7 +1,7 @@
from django.contrib.auth import get_user_model
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.mixins import RetrieveModelMixin, ListModelMixin, UpdateModelMixin
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, UpdateModelMixin
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet

View File

@ -1,4 +1,4 @@
from django.contrib.auth import get_user_model, forms
from django.contrib.auth import forms, get_user_model
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _

View File

@ -1,7 +1,6 @@
import pytest
from celery.result import EagerResult
from {{ cookiecutter.project_slug }}.users.tasks import get_users_count
from {{ cookiecutter.project_slug }}.users.tests.factories import UserFactory

View File

@ -1,5 +1,5 @@
import pytest
from django.urls import reverse, resolve
from django.urls import resolve, reverse
from {{ cookiecutter.project_slug }}.users.models import User

View File

@ -1,9 +1,9 @@
from django.urls import path
from {{ cookiecutter.project_slug }}.users.views import (
user_detail_view,
user_redirect_view,
user_update_view,
user_detail_view,
)
app_name = "users"

View File

@ -1,9 +1,9 @@
from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse
from django.views.generic import DetailView, RedirectView, UpdateView
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, RedirectView, UpdateView
User = get_user_model()