Lines Matching defs:collections

2 import collections
3 from collections import defaultdict
1987 if Callable is collections.abc.Callable:
1989 self.assertIs(alias.__origin__, collections.abc.Callable)
2186 # Testing collections.abc.Callable's consistency with typing.Callable
2188 c2 = collections.abc.Callable[[int, str], dict]
2194 Callable = collections.abc.Callable
3314 class Custom(collections.abc.Iterable, Protocol):
3534 class C(collections.abc.Mapping, Generic[T]): ...
3561 self.assertIsInstance(MM(), collections.abc.MutableMapping)
3567 class MM1(MutableMapping[str, str], collections.abc.MutableMapping):
3569 class MM2(collections.abc.MutableMapping, MutableMapping[str, str]):
3571 self.assertEqual(MM2.__bases__, (collections.abc.MutableMapping, Generic))
3792 self.assertIsInstance(C1(), collections.abc.Container)
3793 self.assertIsSubclass(C1, collections.abc.Container)
4282 for c in Callable, collections.abc.Callable:
5525 def f(x: collections.abc.Callable[[int], int]): ...
5526 def g(x: collections.abc.Callable[..., int]): ...
5527 def h(x: collections.abc.Callable[P, int]): ...
5529 self.assertEqual(get_type_hints(f), {'x': collections.abc.Callable[[int], int]})
5530 self.assertEqual(get_type_hints(g), {'x': collections.abc.Callable[..., int]})
5531 self.assertEqual(get_type_hints(h), {'x': collections.abc.Callable[P, int]})
5553 self.assertIs(get_origin(Callable), collections.abc.Callable)
5592 self.assertEqual(get_args(collections.abc.Callable[[int], str]), ([int], str))
5593 self.assertEqual(get_args(collections.abc.Callable[..., str]), (..., str))
5594 self.assertEqual(get_args(collections.abc.Callable[[], str]), ([], str))
5595 self.assertEqual(get_args(collections.abc.Callable[[int], str]),
5726 self.assertIsSubclass(collections.deque, typing.Deque)
5728 self.assertIsInstance(MyDeque(), collections.deque)
5731 self.assertIsSubclass(collections.Counter, typing.Counter)
5796 self.assertIs(type(typing.DefaultDict()), collections.defaultdict)
5797 self.assertIs(type(typing.DefaultDict[KT, VT]()), collections.defaultdict)
5798 self.assertIs(type(typing.DefaultDict[str, int]()), collections.defaultdict)
5808 self.assertIsSubclass(MyDefDict, collections.defaultdict)
5809 self.assertNotIsSubclass(collections.defaultdict, MyDefDict)
5812 self.assertIs(type(typing.OrderedDict()), collections.OrderedDict)
5813 self.assertIs(type(typing.OrderedDict[KT, VT]()), collections.OrderedDict)
5814 self.assertIs(type(typing.OrderedDict[str, int]()), collections.OrderedDict)
5824 self.assertIsSubclass(MyOrdDict, collections.OrderedDict)
5825 self.assertNotIsSubclass(collections.OrderedDict, MyOrdDict)
5828 self.assertIs(type(typing.ChainMap()), collections.ChainMap)
5829 self.assertIs(type(typing.ChainMap[KT, VT]()), collections.ChainMap)
5830 self.assertIs(type(typing.ChainMap[str, int]()), collections.ChainMap)
5842 self.assertIsSubclass(MyChainMap, collections.ChainMap)
5843 self.assertNotIsSubclass(collections.ChainMap, MyChainMap)
5846 self.assertIs(type(typing.Deque()), collections.deque)
5847 self.assertIs(type(typing.Deque[T]()), collections.deque)
5848 self.assertIs(type(typing.Deque[int]()), collections.deque)
5853 self.assertIs(type(typing.Counter()), collections.Counter)
5854 self.assertIs(type(typing.Counter[T]()), collections.Counter)
5855 self.assertIs(type(typing.Counter[int]()), collections.Counter)
5867 self.assertIsInstance(d, collections.Counter)
5986 self.assertIsInstance(MMB[KT, VT](), collections.abc.Mapping)
5988 self.assertIsSubclass(MMA, collections.abc.Mapping)
5989 self.assertIsSubclass(MMB, collections.abc.Mapping)
5990 self.assertIsSubclass(MMC, collections.abc.Mapping)
6003 self.assertIsSubclass(G, collections.abc.Generator)
6004 self.assertIsSubclass(G, collections.abc.Iterable)
6019 self.assertIsSubclass(G, collections.abc.AsyncGenerator)
6020 self.assertIsSubclass(G, collections.abc.AsyncIterable)
6026 self.assertIsInstance(instance, collections.abc.AsyncGenerator)
6027 self.assertIsInstance(instance, collections.abc.AsyncIterable)
6064 collections.abc.MutableMapping.register(M)
6069 class M(collections.abc.Mapping): ...
6073 class S(collections.abc.MutableSequence): ...
6077 class I(collections.abc.Iterable): ...
6080 class A(collections.abc.Mapping, metaclass=abc.ABCMeta): ...
6293 collections.OrderedDict([('name', str), ('id', int)]))
6304 collections.OrderedDict(name=str, cool=int))
6476 self.assertNotIsSubclass(Emp, collections.abc.Sequence)
6496 self.assertNotIsSubclass(Emp, collections.abc.Sequence)
7487 # Test collections.abc.Callable too.
7488 C3 = collections.abc.Callable[P, int]
7491 C4 = collections.abc.Callable[P, T]
7633 for C in Callable, collections.abc.Callable:
7674 collections.abc.Callable[P, T][arg, str]
7863 # Test collections.abc.Callable too.
7864 C3 = collections.abc.Callable[Concatenate[int, P], int]
7867 C4 = collections.abc.Callable[Concatenate[int, T, P], T]
8301 self.assertNotIsInstance(type_to_test, collections.abc.Iterable)