Add isort
parent
60e266fe99
commit
d39764d383
|
|
@ -67,6 +67,9 @@ You want to contribute some code? Great! Here are a few steps to get you started
|
|||
|
||||
.. code:: console
|
||||
|
||||
# (optional) sort imports with isort and check flake8 linting
|
||||
(venv) $ isort --apply
|
||||
(venv) $ flake8 src/drf_yasg testproj tests setup.py
|
||||
# run tests in the current environment, faster than tox
|
||||
(venv) $ pytest --cov
|
||||
# (optional) run tests for other python versions in separate environments
|
||||
|
|
|
|||
|
|
@ -3,5 +3,9 @@ tox>=2.9.1
|
|||
tox-battery>=0.5
|
||||
detox>=0.11
|
||||
|
||||
isort>=4.2
|
||||
flake8>=3.5.0
|
||||
flake8-isort>=2.3
|
||||
|
||||
# do not unpin this (see setup.py)
|
||||
setuptools_scm==1.15.6
|
||||
|
|
|
|||
6
setup.py
6
setup.py
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import distutils.core
|
||||
import io
|
||||
import os
|
||||
|
||||
import sys
|
||||
from setuptools import setup, find_packages
|
||||
import distutils.core
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
requirements_setup = ['setuptools_scm==1.15.6']
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
import re
|
||||
from collections import defaultdict, OrderedDict
|
||||
from collections import OrderedDict, defaultdict
|
||||
|
||||
import uritemplate
|
||||
from django.utils.encoding import force_text
|
||||
from rest_framework import versioning
|
||||
from rest_framework.schemas.generators import SchemaGenerator, EndpointEnumerator as _EndpointEnumerator
|
||||
from rest_framework.schemas.generators import EndpointEnumerator as _EndpointEnumerator
|
||||
from rest_framework.schemas.generators import SchemaGenerator
|
||||
from rest_framework.schemas.inspectors import get_pk_description
|
||||
|
||||
from . import openapi
|
||||
from .app_settings import swagger_settings
|
||||
from .inspectors.field import get_queryset_field, get_basic_type_info
|
||||
from .inspectors.field import get_basic_type_info, get_queryset_field
|
||||
from .openapi import ReferenceResolver
|
||||
|
||||
PATH_PARAMETER_RE = re.compile(r'{(?P<parameter>\w+)}')
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import logging
|
|||
|
||||
from django.utils.encoding import force_text
|
||||
from rest_framework import serializers
|
||||
from rest_framework.utils import json, encoders
|
||||
from rest_framework.utils import encoders, json
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
from .. import openapi
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ from django.db import models
|
|||
from rest_framework import serializers
|
||||
from rest_framework.settings import api_settings as rest_framework_settings
|
||||
|
||||
from .base import NotHandled, SerializerInspector, FieldInspector
|
||||
from .. import openapi
|
||||
from ..errors import SwaggerGenerationError
|
||||
from ..utils import filter_none
|
||||
from .base import FieldInspector, NotHandled, SerializerInspector
|
||||
|
||||
|
||||
class InlineSerializerInspector(SerializerInspector):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
import coreschema
|
||||
from rest_framework.pagination import CursorPagination, PageNumberPagination, LimitOffsetPagination
|
||||
from rest_framework.pagination import CursorPagination, LimitOffsetPagination, PageNumberPagination
|
||||
|
||||
from .base import PaginatorInspector, FilterInspector
|
||||
from .. import openapi
|
||||
from .base import FilterInspector, PaginatorInspector
|
||||
|
||||
|
||||
class CoreAPICompatInspector(PaginatorInspector, FilterInspector):
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ from rest_framework.request import is_form_media_type
|
|||
from rest_framework.schemas import AutoSchema
|
||||
from rest_framework.status import is_success
|
||||
|
||||
from .base import ViewInspector
|
||||
from .. import openapi
|
||||
from ..errors import SwaggerGenerationError
|
||||
from ..utils import force_serializer_instance, no_body, is_list_view, param_list_to_odict, guess_response_status
|
||||
from ..utils import force_serializer_instance, guess_response_status, is_list_view, no_body, param_list_to_odict
|
||||
from .base import ViewInspector
|
||||
|
||||
|
||||
class SwaggerAutoSchema(ViewInspector):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from django.shortcuts import render, resolve_url
|
|||
from rest_framework.renderers import BaseRenderer
|
||||
from rest_framework.utils import json
|
||||
|
||||
from .app_settings import swagger_settings, redoc_settings
|
||||
from .codecs import OpenAPICodecJson, VALIDATORS, OpenAPICodecYaml
|
||||
from .app_settings import redoc_settings, swagger_settings
|
||||
from .codecs import VALIDATORS, OpenAPICodecJson, OpenAPICodecYaml
|
||||
|
||||
|
||||
class _SpecRenderer(BaseRenderer):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import inspect
|
|||
import logging
|
||||
from collections import OrderedDict
|
||||
|
||||
from rest_framework import status, serializers
|
||||
from rest_framework.mixins import RetrieveModelMixin, DestroyModelMixin, UpdateModelMixin
|
||||
from rest_framework import serializers, status
|
||||
from rest_framework.mixins import DestroyModelMixin, RetrieveModelMixin, UpdateModelMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ from rest_framework.views import APIView
|
|||
|
||||
from drf_yasg.app_settings import swagger_settings
|
||||
from .generators import OpenAPISchemaGenerator
|
||||
from .renderers import (
|
||||
SwaggerJSONRenderer, SwaggerYAMLRenderer, SwaggerUIRenderer, ReDocRenderer, OpenAPIRenderer,
|
||||
)
|
||||
from .renderers import OpenAPIRenderer, ReDocRenderer, SwaggerJSONRenderer, SwaggerUIRenderer, SwaggerYAMLRenderer
|
||||
|
||||
SPEC_RENDERERS = (SwaggerYAMLRenderer, SwaggerJSONRenderer, OpenAPIRenderer)
|
||||
UI_RENDERERS = {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework import serializers
|
||||
|
||||
from articles.models import Article
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class ArticleSerializer(serializers.ModelSerializer):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from articles import serializers
|
|||
from articles.models import Article
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.app_settings import swagger_settings
|
||||
from drf_yasg.inspectors import SwaggerAutoSchema, FieldInspector, CoreAPICompatInspector, NotHandled
|
||||
from drf_yasg.inspectors import CoreAPICompatInspector, FieldInspector, NotHandled, SwaggerAutoSchema
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.contrib.auth import get_user_model
|
||||
from rest_framework import serializers
|
||||
|
||||
from snippets.models import Snippet, LANGUAGE_CHOICES, STYLE_CHOICES
|
||||
from snippets.models import LANGUAGE_CHOICES, STYLE_CHOICES, Snippet
|
||||
|
||||
|
||||
class LanguageSerializer(serializers.Serializer):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from django.conf.urls import url, include
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
from rest_framework import permissions
|
||||
from rest_framework.decorators import api_view
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ from rest_framework.response import Response
|
|||
from rest_framework.views import APIView
|
||||
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.utils import swagger_auto_schema, no_body
|
||||
from users.serializers import UserSerializerrr, UserListQuerySerializer
|
||||
from drf_yasg.utils import no_body, swagger_auto_schema
|
||||
from users.serializers import UserListQuerySerializer, UserSerializerrr
|
||||
|
||||
|
||||
class UserList(APIView):
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from collections import OrderedDict
|
|||
|
||||
import pytest
|
||||
|
||||
from drf_yasg import openapi, codecs
|
||||
from drf_yasg import codecs, openapi
|
||||
from drf_yasg.codecs import yaml_sane_load
|
||||
from drf_yasg.generators import OpenAPISchemaGenerator
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
from django.conf.urls import url
|
||||
from django.conf.urls import include
|
||||
from django.conf.urls import include, url
|
||||
from rest_framework import permissions
|
||||
|
||||
import testproj.urls
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from django.conf.urls import url
|
|||
from rest_framework import fields
|
||||
|
||||
from snippets.serializers import SnippetSerializer
|
||||
|
||||
from .ns_version1 import SnippetList as SnippetListV1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from django.conf.urls import url, include
|
||||
from django.conf.urls import include, url
|
||||
from rest_framework import versioning
|
||||
|
||||
from testproj.urls import SchemaView
|
||||
|
||||
from . import ns_version1, ns_version2
|
||||
|
||||
VERSION_PREFIX_NS = r"^versioned/ns/"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from django.conf.urls import url
|
||||
from rest_framework import generics, versioning, fields
|
||||
from rest_framework import fields, generics, versioning
|
||||
|
||||
from snippets.models import Snippet
|
||||
from snippets.serializers import SnippetSerializer
|
||||
|
|
|
|||
11
tox.ini
11
tox.ini
|
|
@ -39,6 +39,7 @@ pip_pre = True
|
|||
skip_install = true
|
||||
deps =
|
||||
flake8
|
||||
flake8-isort
|
||||
commands =
|
||||
flake8 src/drf_yasg testproj tests setup.py
|
||||
|
||||
|
|
@ -56,3 +57,13 @@ python_paths = testproj
|
|||
[flake8]
|
||||
max-line-length = 120
|
||||
exclude = **/migrations/*
|
||||
|
||||
[isort]
|
||||
skip = .eggs,.tox,docs
|
||||
skip_glob = **/migrations/*
|
||||
atomic = true
|
||||
multi_line_output = 5
|
||||
line_length = 120
|
||||
known_standard_library = types
|
||||
known_third_party = pytest,_pytest,django,rest_framework
|
||||
known_first_party = drf_yasg
|
||||
|
|
|
|||
Loading…
Reference in New Issue