From 11bd9602f0888e72828ed37eab37b76414894ff7 Mon Sep 17 00:00:00 2001 From: PrettyWood Date: Sun, 17 Jan 2021 19:49:37 +0100 Subject: [PATCH] chore: fix lint --- pydantic/annotated_types.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pydantic/annotated_types.py b/pydantic/annotated_types.py index 5a36e303a4..35ee5bce73 100644 --- a/pydantic/annotated_types.py +++ b/pydantic/annotated_types.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING, Any, Dict, FrozenSet, NamedTuple, Type +from typing import TYPE_CHECKING, Any, Dict, FrozenSet, NamedTuple, Optional, Type from .fields import Required from .main import BaseConfig, BaseModel, create_model @@ -12,7 +12,9 @@ class TypedDict(Dict[str, Any]): __optional_keys__: FrozenSet[str] -def typeddict_to_model(typeddict_cls: Type['TypedDict'], *, config: Type['BaseConfig']) -> Type['BaseModel']: +def typeddict_to_model( + typeddict_cls: Type['TypedDict'], *, config: Optional[Type['BaseConfig']] = None +) -> Type['BaseModel']: """ Convert a `TypedDict` to a `BaseModel` Since `typing.TypedDict` in Python 3.8 does not store runtime information about optional keys, @@ -40,9 +42,7 @@ def typeddict_to_model(typeddict_cls: Type['TypedDict'], *, config: Type['BaseCo field_name: (field_type, default_value) for field_name, field_type in typeddict_cls.__annotations__.items() } - return create_model( - f'{typeddict_cls.__name__}Model', __config__=config, **field_definitions - ) + return create_model(f'{typeddict_cls.__name__}Model', __config__=config, **field_definitions) def namedtuple_to_model(namedtuple_cls: Type['NamedTuple']) -> Type['BaseModel']: