Skip to content

Commit

Permalink
[VNG-Realisatie#222] run black
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonny Bakker committed Sep 23, 2022
1 parent 0e68656 commit 63277a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
8 changes: 3 additions & 5 deletions vng_api_common/extensions/utils.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from typing import Optional, Type

from django.db import models

from rest_framework import serializers
from rest_framework.utils.model_meta import get_field_info

from django.utils.translation import gettext_lazy as _

from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiExample, OpenApiParameter
from rest_framework import serializers
from rest_framework.status import HTTP_200_OK
from rest_framework.utils.model_meta import get_field_info
from rest_framework.views import APIView


CACHE_REQUEST_HEADERS = [
OpenApiParameter(
name="If-None-Match",
Expand Down Expand Up @@ -42,6 +39,7 @@
)
]


def get_target_field(model: Type[models.Model], field: str) -> Optional[models.Field]:
"""
Retrieve the end-target that ``field`` points to.
Expand Down
22 changes: 8 additions & 14 deletions vng_api_common/management/commands/generate_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from drf_spectacular.management.commands.spectacular import (
Command as SpectacularCommand,
)
from drf_spectacular.renderers import OpenApiJsonRenderer, OpenApiYamlRenderer
from drf_spectacular.settings import spectacular_settings
from rest_framework.settings import api_settings
from rest_framework.test import APIRequestFactory, force_authenticate
Expand Down Expand Up @@ -66,7 +65,7 @@ def add_arguments(self, parser):
default=False,
action="store_true",
help="Overwrite the output file if it already exists. "
"Default behavior is to stop if the output file exists.",
"Default behavior is to stop if the output file exists.",
)
parser.add_argument(
"-m",
Expand All @@ -75,7 +74,7 @@ def add_arguments(self, parser):
default=False,
action="store_true",
help="Use a mock request when generating the swagger schema. This is useful if your views or serializers "
"depend on context from a request in order to function.",
"depend on context from a request in order to function.",
)
parser.add_argument(
"-u",
Expand All @@ -96,10 +95,10 @@ def add_arguments(self, parser):
default=False,
action="store_true",
help="Hides endpoints not accesible to the target user. If --user is not given, only shows endpoints that "
"are accesible to unauthenticated users.\n"
"This has the same effect as passing public=False to get_schema_view() or "
"OpenAPISchemaGenerator.get_schema().\n"
"This option implies --mock-request.",
"are accesible to unauthenticated users.\n"
"This has the same effect as passing public=False to get_schema_view() or "
"OpenAPISchemaGenerator.get_schema().\n"
"This option implies --mock-request.",
)

def get_mock_request(self, url, format, user=None):
Expand Down Expand Up @@ -138,10 +137,7 @@ def handle(
api_root = reverse("api-root", kwargs={"version": get_major_version()})
except NoReverseMatch:
api_root = reverse("api-root")
api_url = (
api_url
or f"http://example.com{api_root}" # noqa
)
api_url = api_url or f"http://example.com{api_root}" # noqa
if user:
# Only call get_user_model if --user was passed in order to
# avoid crashing if auth is not configured in the project
Expand All @@ -168,9 +164,7 @@ def handle(
generator_class_import = spectacular_settings.DEFAULT_GENERATOR_CLASS

generator = generator_class_import(
urlconf=urlconf,
api_version=api_version,
url=api_url
urlconf=urlconf, api_version=api_version, url=api_url
)

schema = generator.get_schema(request=request, public=not private)
Expand Down

0 comments on commit 63277a5

Please sign in to comment.