Skip to content

Commit

Permalink
make #4083 compatible with py3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed May 19, 2022
1 parent 91a2ffc commit 6ac2fcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pydantic/generics.py
Expand Up @@ -31,13 +31,13 @@

Parametrization = Mapping[TypeVarType, Type[Any]]

_generic_types_cache: LimitedDict[Tuple[Type[Any], Union[Any, Tuple[Any, ...]]], Type[BaseModel]] = LimitedDict()
_generic_types_cache: 'LimitedDict[Tuple[Type[Any], Union[Any, Tuple[Any, ...]]], Type[BaseModel]]' = LimitedDict()
# _assigned_parameters is a Mapping from parametrized version of generic models to assigned types of parametrizations
# as captured during construction of the class (not instances).
# E.g., for generic model `Model[A, B]`, when parametrized model `Model[int, str]` is created,
# `Model[int, str]`: {A: int, B: str}` will be stored in `_assigned_parameters`.
# (This information is only otherwise available after creation from the class name string).
_assigned_parameters: LimitedDict[Type[Any], Parametrization] = LimitedDict()
_assigned_parameters: 'LimitedDict[Type[Any], Parametrization]' = LimitedDict()


class GenericModel(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions pydantic/utils.py
Expand Up @@ -784,6 +784,6 @@ def __setitem__(self, __key: Any, __value: Any) -> None:
for key in to_remove:
del self[key]

def __class_getitem__(cls, *args: Any) -> Any:
# to avoid errors with 3.7
def __class_getitem__(cls, *args: Any) -> Any: # pragma: no cover
# just in case LimitedDict is used in type annotations
pass

0 comments on commit 6ac2fcd

Please sign in to comment.