Lines Matching defs:Generic

8 * Generic, Protocol, and internal machinery to support generic aliases.
52 'Generic',
180 invalid_generic_forms = (Generic, Protocol)
194 if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):
978 as for generic function definitions. See class Generic for more
979 information on generic types. Generic functions work as follows:
1046 class C(Generic[*Ts]): ...
1175 Generics. See class Generic for more information on generic types. An
1274 if isinstance(b, _BaseGenericAlias) or issubclass(b, Generic):
1277 res.append(Generic)
1309 # Special typing constructs Union, Optional, Generic, Callable and Tuple
1331 # class C(Generic[T]): pass
1381 # class A(Generic[T1]): pass
1390 if self.__origin__ in (Generic, Protocol):
1391 # Can't subscript Generic[...] or Protocol[...].
1411 # class A(Generic[T1, T2]): pass
1472 # class A(Generic[*Ts]): ...
1485 # class Base(Generic[P]): ...
1528 if self.__origin__ is Generic:
1726 # `Generic[]`.)
1727 class Bar(Generic[Unpack[Ts]]): ...
1734 class Bar(Generic[*Ts]): ...
1773 class Generic:
1780 class Mapping(Generic[KT, VT]):
1805 classes in the first place with `class Foo(Generic[T]): ...`.
1811 if cls in (Generic, Protocol):
1812 # Generic and Protocol can only be subscripted with unique type variables.
1825 # Subscripting a regular Generic subclass.
1847 error = Generic in cls.__orig_bases__
1849 error = (Generic in cls.__bases__ and
1853 raise TypeError("Cannot inherit from plain Generic")
1856 # Look for Generic[T1, ..., Tn].
1859 # Also check for and reject plain Generic,
1860 # and reject multiple Generic[...].
1864 base.__origin__ is Generic):
1867 "Cannot inherit from Generic[...] multiple times.")
1876 f" not listed in Generic[{s_args}]")
1904 if base.__name__ in ('Protocol', 'Generic'):
2000 class Protocol(Generic, metaclass=_ProtocolMeta):
2075 issubclass(other, Generic) and other._is_protocol):
2090 if not (base in (object, Generic) or
2093 issubclass(base, Generic) and base._is_protocol):
2239 if not issubclass(cls, Generic) or not cls._is_protocol:
2411 assert get_origin(Generic) is Generic
2412 assert get_origin(Generic[T]) is Generic
2422 if tp is Generic:
2423 return Generic
2861 if base is not _NamedTuple and base is not Generic:
2863 'can only inherit from a NamedTuple type and Generic')
2879 if Generic in bases:
2880 class_getitem = Generic.__class_getitem__.__func__
2888 if Generic in bases:
2939 if type(base) is not _TypedDictMeta and base is not Generic:
2943 if any(issubclass(b, Generic) for b in bases):
2944 generic_base = (Generic,)
3181 class IO(Generic[AnyStr]):
3182 """Generic base class for TextIO and BinaryIO.