[3.7] bpo-33652: Improve pickle support in the typing module. (GH-7123) by miss-islington · Pull Request #7132 · python/cpython
def _find_name(mod, name): return getattr(sys.modules[mod], name)
class TypeVar(_Final, _Immutable, _root=True): """Type variable.
__slots__ = ('__name__', '__bound__', '__constraints__', '__covariant__', '__contravariant__', '_def_mod') '__covariant__', '__contravariant__')
def __init__(self, name, *constraints, bound=None, covariant=False, contravariant=False):
def __getstate__(self): return {'name': self.__name__,
def __reduce__(self): return (_find_name, (self._def_mod, self.__name__)) return self.__name__
# Special typing constructs Union, Optional, Generic, Callable and Tuple
if self._name: origin = globals()[self._name] else: origin = self.__origin__ if (origin is Callable and not (len(self.__args__) == 2 and self.__args__[0] is Ellipsis)): args = list(self.__args__[:-1]), self.__args__[-1] else: args = tuple(self.__args__) if len(args) == 1 and not isinstance(args[0], tuple): args, = args return operator.getitem, (origin, args)
class _VariadicGenericAlias(_GenericAlias, _root=True):