From ec624a27be2bc9abc9063263fd7a6173ab47f323 Mon Sep 17 00:00:00 2001 From: Daniyar Yeralin Date: Wed, 12 Aug 2020 14:40:38 -0400 Subject: [PATCH] Format proposed code --- fastapi/dependencies/utils.py | 21 +++++++++------------ tests/main.py | 2 +- tests/test_query.py | 7 +++++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index d09ccde8f..843f59bf6 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -34,6 +34,7 @@ from pydantic.error_wrappers import ErrorWrapper from pydantic.errors import MissingError from pydantic.fields import ( SHAPE_LIST, + SHAPE_MAPPING, SHAPE_SEQUENCE, SHAPE_SET, SHAPE_SINGLETON, @@ -41,7 +42,7 @@ from pydantic.fields import ( SHAPE_TUPLE_ELLIPSIS, FieldInfo, ModelField, - Required, SHAPE_MAPPING, + Required, ) from pydantic.schema import get_annotation_from_field_info from pydantic.typing import ForwardRef, evaluate_forwardref @@ -69,13 +70,9 @@ sequence_shape_to_type = { SHAPE_TUPLE_ELLIPSIS: list, } -mapping_shapes = { - SHAPE_MAPPING -} -mapping_types = (dict) -mapping_shapes_to_type = { - SHAPE_MAPPING: dict -} +mapping_shapes = {SHAPE_MAPPING} +mapping_types = dict +mapping_shapes_to_type = {SHAPE_MAPPING: dict} multipart_not_installed_error = ( 'Form data requires "python-multipart" to be installed. \n' @@ -343,10 +340,10 @@ def get_dependant( add_param_to_fields(field=param_field, dependant=dependant) elif is_scalar_field(field=param_field): add_param_to_fields(field=param_field, dependant=dependant) - elif isinstance( - param.default, (params.Query, params.Header) - ) and (is_scalar_sequence_field(param_field) - or is_scalar_mapping_field(param_field)): + elif isinstance(param.default, (params.Query, params.Header)) and ( + is_scalar_sequence_field(param_field) + or is_scalar_mapping_field(param_field) + ): add_param_to_fields(field=param_field, dependant=dependant) else: field_info = param_field.field_info diff --git a/tests/main.py b/tests/main.py index fdd16f2d2..17b380f6d 100644 --- a/tests/main.py +++ b/tests/main.py @@ -1,5 +1,5 @@ import http -from typing import Optional, Dict +from typing import Dict, Optional from fastapi import FastAPI, Path, Query diff --git a/tests/test_query.py b/tests/test_query.py index 6c4f4b0e8..934d34136 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -53,8 +53,11 @@ response_not_valid_int = { ("/query/param-required/int", 422, response_missing), ("/query/param-required/int?query=50", 200, "foo bar 50"), ("/query/param-required/int?query=foo", 422, response_not_valid_int), - ("/query/params?first-query=1&second-query=2", 200, "foo bar {'first-query': 1, " - "'second-query': 2}") + ( + "/query/params?first-query=1&second-query=2", + 200, + "foo bar {'first-query': 1, " "'second-query': 2}", + ), ], ) def test_get_path(path, expected_status, expected_response):