Coverage for pydantic/generics.py: 100.00%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

152 statements  

1import sys linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

2import typing linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

3from typing import ( linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

4 TYPE_CHECKING, 

5 Any, 

6 ClassVar, 

7 Dict, 

8 Generic, 

9 Iterator, 

10 List, 

11 Mapping, 

12 Optional, 

13 Tuple, 

14 Type, 

15 TypeVar, 

16 Union, 

17 cast, 

18) 

19 

20from typing_extensions import Annotated linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

21 

22from .class_validators import gather_all_validators linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

23from .fields import DeferredType linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

24from .main import BaseModel, create_model linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

25from .types import JsonWrapper linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

26from .typing import display_as_type, get_all_type_hints, get_args, get_origin, typing_base linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

27from .utils import all_identical, lenient_issubclass linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

28 

29_generic_types_cache: Dict[Tuple[Type[Any], Union[Any, Tuple[Any, ...]]], Type[BaseModel]] = {} linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

30GenericModelT = TypeVar('GenericModelT', bound='GenericModel') linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

31TypeVarType = Any # since mypy doesn't allow the use of TypeVar as a type linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

32 

33Parametrization = Mapping[TypeVarType, Type[Any]] linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

34 

35# _assigned_parameters is a Mapping from parametrized version of generic models to assigned types of parametrizations 

36# as captured during construction of the class (not instances). 

37# E.g., for generic model `Model[A, B]`, when parametrized model `Model[int, str]` is created, 

38# `Model[int, str]`: {A: int, B: str}` will be stored in `_assigned_parameters`. 

39# (This information is only otherwise available after creation from the class name string). 

40_assigned_parameters: Dict[Type[Any], Parametrization] = {} linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

41 

42 

43class GenericModel(BaseModel): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

44 __slots__ = () linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

45 __concrete__: ClassVar[bool] = False linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

46 

47 if TYPE_CHECKING: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

48 # Putting this in a TYPE_CHECKING block allows us to replace `if Generic not in cls.__bases__` with 

49 # `not hasattr(cls, "__parameters__")`. This means we don't need to force non-concrete subclasses of 

50 # `GenericModel` to also inherit from `Generic`, which would require changes to the use of `create_model` below. 

51 __parameters__: ClassVar[Tuple[TypeVarType, ...]] 

52 

53 # Setting the return type as Type[Any] instead of Type[BaseModel] prevents PyCharm warnings 

54 def __class_getitem__(cls: Type[GenericModelT], params: Union[Type[Any], Tuple[Type[Any], ...]]) -> Type[Any]: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

55 """Instantiates a new class from a generic class `cls` and type variables `params`. 

56 

57 :param params: Tuple of types the class . Given a generic class 

58 `Model` with 2 type variables and a concrete model `Model[str, int]`, 

59 the value `(str, int)` would be passed to `params`. 

60 :return: New model class inheriting from `cls` with instantiated 

61 types described by `params`. If no parameters are given, `cls` is 

62 returned as is. 

63 

64 """ 

65 cached = _generic_types_cache.get((cls, params)) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

66 if cached is not None: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

67 return cached linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

68 if cls.__concrete__ and Generic not in cls.__bases__: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

69 raise TypeError('Cannot parameterize a concrete instantiation of a generic model') linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

70 if not isinstance(params, tuple): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

71 params = (params,) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

72 if cls is GenericModel and any(isinstance(param, TypeVar) for param in params): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

73 raise TypeError('Type parameters should be placed on typing.Generic, not GenericModel') linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

74 if not hasattr(cls, '__parameters__'): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

75 raise TypeError(f'Type {cls.__name__} must inherit from typing.Generic before being parameterized') linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

76 

77 check_parameters_count(cls, params) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

78 # Build map from generic typevars to passed params 

79 typevars_map: Dict[TypeVarType, Type[Any]] = dict(zip(cls.__parameters__, params)) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

80 if all_identical(typevars_map.keys(), typevars_map.values()) and typevars_map: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

81 return cls # if arguments are equal to parameters it's the same object linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

82 

83 # Create new model with original model as parent inserting fields with DeferredType. 

84 model_name = cls.__concrete_name__(params) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

85 validators = gather_all_validators(cls) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

86 

87 type_hints = get_all_type_hints(cls).items() linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

88 instance_type_hints = {k: v for k, v in type_hints if get_origin(v) is not ClassVar} linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

89 

90 fields = {k: (DeferredType(), cls.__fields__[k].field_info) for k in instance_type_hints if k in cls.__fields__} linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

91 

92 model_module, called_globally = get_caller_frame_info() linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

93 created_model = cast( linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

94 Type[GenericModel], # casting ensures mypy is aware of the __concrete__ and __parameters__ attributes 

95 create_model( 

96 model_name, 

97 __module__=model_module or cls.__module__, 

98 __base__=(cls,) + tuple(cls.__parameterized_bases__(typevars_map)), 

99 __config__=None, 

100 __validators__=validators, 

101 **fields, 

102 ), 

103 ) 

104 

105 _assigned_parameters[created_model] = typevars_map linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

106 

107 if called_globally: # create global reference and therefore allow pickling linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

108 object_by_reference = None linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

109 reference_name = model_name linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

110 reference_module_globals = sys.modules[created_model.__module__].__dict__ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

111 while object_by_reference is not created_model: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

112 object_by_reference = reference_module_globals.setdefault(reference_name, created_model) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

113 reference_name += '_' linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

114 

115 created_model.Config = cls.Config linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

116 

117 # Find any typevars that are still present in the model. 

118 # If none are left, the model is fully "concrete", otherwise the new 

119 # class is a generic class as well taking the found typevars as 

120 # parameters. 

121 new_params = tuple( linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

122 {param: None for param in iter_contained_typevars(typevars_map.values())} 

123 ) # use dict as ordered set 

124 created_model.__concrete__ = not new_params linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

125 if new_params: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

126 created_model.__parameters__ = new_params linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

127 

128 # Save created model in cache so we don't end up creating duplicate 

129 # models that should be identical. 

130 _generic_types_cache[(cls, params)] = created_model linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

131 if len(params) == 1: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

132 _generic_types_cache[(cls, params[0])] = created_model linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

133 

134 # Recursively walk class type hints and replace generic typevars 

135 # with concrete types that were passed. 

136 _prepare_model_fields(created_model, fields, instance_type_hints, typevars_map) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

137 

138 return created_model linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

139 

140 @classmethod linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

141 def __concrete_name__(cls: Type[Any], params: Tuple[Type[Any], ...]) -> str: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

142 """Compute class name for child classes. 

143 

144 :param params: Tuple of types the class . Given a generic class 

145 `Model` with 2 type variables and a concrete model `Model[str, int]`, 

146 the value `(str, int)` would be passed to `params`. 

147 :return: String representing a the new class where `params` are 

148 passed to `cls` as type variables. 

149 

150 This method can be overridden to achieve a custom naming scheme for GenericModels. 

151 """ 

152 param_names = [display_as_type(param) for param in params] linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

153 params_component = ', '.join(param_names) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

154 return f'{cls.__name__}[{params_component}]' linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

155 

156 @classmethod linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

157 def __parameterized_bases__(cls, typevars_map: Parametrization) -> Iterator[Type[Any]]: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

158 """ 

159 Returns unbound bases of cls parameterised to given type variables 

160 

161 :param typevars_map: Dictionary of type applications for binding subclasses. 

162 Given a generic class `Model` with 2 type variables [S, T] 

163 and a concrete model `Model[str, int]`, 

164 the value `{S: str, T: int}` would be passed to `typevars_map`. 

165 :return: an iterator of generic sub classes, parameterised by `typevars_map` 

166 and other assigned parameters of `cls` 

167 

168 e.g.: 

169 ``` 

170 class A(GenericModel, Generic[T]): 

171 ... 

172 

173 class B(A[V], Generic[V]): 

174 ... 

175 

176 assert A[int] in B.__parameterized_bases__({V: int}) 

177 ``` 

178 """ 

179 

180 def build_base_model( linux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.8macos-py3.9macos-py3.10windows-py3.8windows-py3.9windows-py3.10

181 base_model: Type[GenericModel], mapped_types: Parametrization 

182 ) -> Iterator[Type[GenericModel]]: 

183 base_parameters = tuple([mapped_types[param] for param in base_model.__parameters__]) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

184 parameterized_base = base_model.__class_getitem__(base_parameters) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

185 if parameterized_base is base_model or parameterized_base is cls: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

186 # Avoid duplication in MRO 

187 return linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

188 yield parameterized_base linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

189 

190 for base_model in cls.__bases__: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

191 if not issubclass(base_model, GenericModel): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

192 # not a class that can be meaningfully parameterized 

193 continue linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

194 elif not getattr(base_model, '__parameters__', None): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

195 # base_model is "GenericModel" (and has no __parameters__) 

196 # or 

197 # base_model is already concrete, and will be included transitively via cls. 

198 continue linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

199 elif cls in _assigned_parameters: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

200 if base_model in _assigned_parameters: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

201 # cls is partially parameterised but not from base_model 

202 # e.g. cls = B[S], base_model = A[S] 

203 # B[S][int] should subclass A[int], (and will be transitively via B[int]) 

204 # but it's not viable to consistently subclass types with arbitrary construction 

205 # So don't attempt to include A[S][int] 

206 continue linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

207 else: # base_model not in _assigned_parameters: 

208 # cls is partially parameterized, base_model is original generic 

209 # e.g. cls = B[str, T], base_model = B[S, T] 

210 # Need to determine the mapping for the base_model parameters 

211 mapped_types: Parametrization = { linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

212 key: typevars_map.get(value, value) for key, value in _assigned_parameters[cls].items() 

213 } 

214 yield from build_base_model(base_model, mapped_types) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

215 else: 

216 # cls is base generic, so base_class has a distinct base 

217 # can construct the Parameterised base model using typevars_map directly 

218 yield from build_base_model(base_model, typevars_map) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

219 

220 

221def replace_types(type_: Any, type_map: Mapping[Any, Any]) -> Any: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

222 """Return type with all occurrences of `type_map` keys recursively replaced with their values. 

223 

224 :param type_: Any type, class or generic alias 

225 :param type_map: Mapping from `TypeVar` instance to concrete types. 

226 :return: New type representing the basic structure of `type_` with all 

227 `typevar_map` keys recursively replaced. 

228 

229 >>> replace_types(Tuple[str, Union[List[str], float]], {str: int}) 

230 Tuple[int, Union[List[int], float]] 

231 

232 """ 

233 if not type_map: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

234 return type_ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

235 

236 type_args = get_args(type_) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

237 origin_type = get_origin(type_) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

238 

239 if origin_type is Annotated: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

240 annotated_type, *annotations = type_args linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

241 return Annotated[replace_types(annotated_type, type_map), tuple(annotations)] linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

242 

243 # Having type args is a good indicator that this is a typing module 

244 # class instantiation or a generic alias of some sort. 

245 if type_args: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

246 resolved_type_args = tuple(replace_types(arg, type_map) for arg in type_args) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

247 if all_identical(type_args, resolved_type_args): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

248 # If all arguments are the same, there is no need to modify the 

249 # type or create a new object at all 

250 return type_ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

251 if ( linux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.8macos-py3.9macos-py3.10windows-py3.8windows-py3.9windows-py3.10

252 origin_type is not None 

253 and isinstance(type_, typing_base) 

254 and not isinstance(origin_type, typing_base) 

255 and getattr(type_, '_name', None) is not None 

256 ): 

257 # In python < 3.9 generic aliases don't exist so any of these like `list`, 

258 # `type` or `collections.abc.Callable` need to be translated. 

259 # See: https://www.python.org/dev/peps/pep-0585 

260 origin_type = getattr(typing, type_._name) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

261 assert origin_type is not None linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

262 return origin_type[resolved_type_args] linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

263 

264 # We handle pydantic generic models separately as they don't have the same 

265 # semantics as "typing" classes or generic aliases 

266 if not origin_type and lenient_issubclass(type_, GenericModel) and not type_.__concrete__: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

267 type_args = type_.__parameters__ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

268 resolved_type_args = tuple(replace_types(t, type_map) for t in type_args) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

269 if all_identical(type_args, resolved_type_args): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

270 return type_ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

271 return type_[resolved_type_args] linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

272 

273 # Handle special case for typehints that can have lists as arguments. 

274 # `typing.Callable[[int, str], int]` is an example for this. 

275 if isinstance(type_, (List, list)): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

276 resolved_list = list(replace_types(element, type_map) for element in type_) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

277 if all_identical(type_, resolved_list): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

278 return type_ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

279 return resolved_list linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

280 

281 # For JsonWrapperValue, need to handle its inner type to allow correct parsing 

282 # of generic Json arguments like Json[T] 

283 if not origin_type and lenient_issubclass(type_, JsonWrapper): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

284 type_.inner_type = replace_types(type_.inner_type, type_map) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

285 return type_ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

286 

287 # If all else fails, we try to resolve the type directly and otherwise just 

288 # return the input with no modifications. 

289 return type_map.get(type_, type_) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

290 

291 

292def check_parameters_count(cls: Type[GenericModel], parameters: Tuple[Any, ...]) -> None: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

293 actual = len(parameters) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

294 expected = len(cls.__parameters__) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

295 if actual != expected: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

296 description = 'many' if actual > expected else 'few' linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

297 raise TypeError(f'Too {description} parameters for {cls.__name__}; actual {actual}, expected {expected}') linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

298 

299 

300DictValues: Type[Any] = {}.values().__class__ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

301 

302 

303def iter_contained_typevars(v: Any) -> Iterator[TypeVarType]: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

304 """Recursively iterate through all subtypes and type args of `v` and yield any typevars that are found.""" 

305 if isinstance(v, TypeVar): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

306 yield v linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

307 elif hasattr(v, '__parameters__') and not get_origin(v) and lenient_issubclass(v, GenericModel): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

308 yield from v.__parameters__ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

309 elif isinstance(v, (DictValues, list)): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

310 for var in v: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

311 yield from iter_contained_typevars(var) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

312 else: 

313 args = get_args(v) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

314 for arg in args: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

315 yield from iter_contained_typevars(arg) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

316 

317 

318def get_caller_frame_info() -> Tuple[Optional[str], bool]: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

319 """ 

320 Used inside a function to check whether it was called globally 

321 

322 Will only work against non-compiled code, therefore used only in pydantic.generics 

323 

324 :returns Tuple[module_name, called_globally] 

325 """ 

326 try: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

327 previous_caller_frame = sys._getframe(2) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

328 except ValueError as e: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

329 raise RuntimeError('This function must be used inside another function') from e linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

330 except AttributeError: # sys module does not have _getframe function, so there's nothing we can do about it linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

331 return None, False linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

332 frame_globals = previous_caller_frame.f_globals linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

333 return frame_globals.get('__name__'), previous_caller_frame.f_locals is frame_globals linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

334 

335 

336def _prepare_model_fields( linux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.8macos-py3.9macos-py3.10windows-py3.8windows-py3.9windows-py3.10

337 created_model: Type[GenericModel], 

338 fields: Mapping[str, Any], 

339 instance_type_hints: Mapping[str, type], 

340 typevars_map: Mapping[Any, type], 

341) -> None: 

342 """ 

343 Replace DeferredType fields with concrete type hints and prepare them. 

344 """ 

345 

346 for key, field in created_model.__fields__.items(): linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

347 if key not in fields: linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

348 assert field.type_.__class__ is not DeferredType linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

349 # https://github.com/nedbat/coveragepy/issues/198 

350 continue # pragma: no cover linux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yesmacos-py3.10windows-py3.10

351 

352 assert field.type_.__class__ is DeferredType, field.type_.__class__ linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

353 

354 field_type_hint = instance_type_hints[key] linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

355 concrete_type = replace_types(field_type_hint, typevars_map) linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

356 field.type_ = concrete_type linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

357 field.outer_type_ = concrete_type linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

358 field.prepare() linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10

359 created_model.__annotations__[key] = concrete_type linux-py3.7-compiled-no-deps-nolinux-py3.7-compiled-yes-deps-nolinux-py3.7-compiled-yes-deps-yeslinux-py3.8-compiled-no-deps-nolinux-py3.8-compiled-yes-deps-nolinux-py3.8-compiled-yes-deps-yeslinux-py3.9-compiled-no-deps-nolinux-py3.9-compiled-yes-deps-nolinux-py3.9-compiled-yes-deps-yeslinux-py3.10-compiled-no-deps-nolinux-py3.10-compiled-yes-deps-nolinux-py3.10-compiled-yes-deps-yeslinux-py3.10-mypy0.910linux-py3.10-mypy0.920linux-py3.10-mypy0.921macos-py3.7macos-py3.8macos-py3.9macos-py3.10windows-py3.7windows-py3.8windows-py3.9windows-py3.10