|
1 | 1 | from typing import Any
|
| 2 | +from typing import Dict |
2 | 3 | from typing import Generic
|
3 |
| -from typing import Hashable |
4 | 4 | from typing import Iterable
|
5 | 5 | from typing import Iterator
|
6 | 6 | from typing import Mapping
|
7 |
| -from typing import MutableMapping |
8 |
| -from typing import NoReturn |
9 |
| -from typing import overload |
| 7 | +from typing import Optional |
10 | 8 | from typing import Tuple
|
11 | 9 | from typing import Type
|
12 |
| -from typing import TypeVar |
13 | 10 | from typing import Union
|
| 11 | +from typing import overload |
14 | 12 |
|
15 |
| - |
16 |
| -K = TypeVar('K', bound=Hashable) |
17 |
| -V = TypeVar('V', bound=Any) |
18 |
| -D = TypeVar('D', bound=Any) |
19 |
| - |
20 |
| - |
21 |
| -class BitmapNode: ... |
22 |
| - |
23 |
| - |
24 |
| -class MapKeys(Generic[K]): |
25 |
| - def __init__(self, c: int, m: BitmapNode) -> None: ... |
26 |
| - def __len__(self) -> int: ... |
27 |
| - def __iter__(self) -> Iterator[K]: ... |
28 |
| - |
29 |
| - |
30 |
| -class MapValues(Generic[V]): |
31 |
| - def __init__(self, c: int, m: BitmapNode) -> None: ... |
32 |
| - def __len__(self) -> int: ... |
33 |
| - def __iter__(self) -> Iterator[V]: ... |
34 |
| - |
35 |
| - |
36 |
| -class MapItems(Generic[K, V]): |
37 |
| - def __init__(self, c: int, m: BitmapNode) -> None: ... |
38 |
| - def __len__(self) -> int: ... |
39 |
| - def __iter__(self) -> Iterator[Tuple[K, V]]: ... |
| 13 | +from ._protocols import IterableItems |
| 14 | +from ._protocols import MapItems |
| 15 | +from ._protocols import MapKeys |
| 16 | +from ._protocols import MapMutation |
| 17 | +from ._protocols import MapValues |
| 18 | +from ._protocols import HT |
| 19 | +from ._protocols import KT |
| 20 | +from ._protocols import T |
| 21 | +from ._protocols import VT_co |
40 | 22 |
|
41 | 23 |
|
42 |
| -class Map(Mapping[K, V]): |
| 24 | +class Map(Mapping[KT, VT_co]): |
43 | 25 | @overload
|
44 |
| - def __init__(self, **kw: V) -> None: ... |
| 26 | + def __init__(self) -> None: ... |
| 27 | + @overload |
| 28 | + def __init__(self: Map[str, VT_co], **kw: VT_co) -> None: ... |
| 29 | + @overload |
| 30 | + def __init__( |
| 31 | + self, __col: Union[IterableItems[KT, VT_co], Iterable[Tuple[KT, VT_co]]] |
| 32 | + ) -> None: ... |
45 | 33 | @overload
|
46 | 34 | def __init__(
|
47 |
| - self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]], **kw: V |
| 35 | + self: Map[Union[KT, str], VT_co], |
| 36 | + __col: Union[IterableItems[KT, VT_co], Iterable[Tuple[KT, VT_co]]], |
| 37 | + **kw: VT_co |
48 | 38 | ) -> None: ...
|
49 |
| - def __reduce__(self) -> Tuple[Type[Map], Tuple[dict]]: ... |
| 39 | + def __reduce__(self) -> Tuple[Type[Map[KT, VT_co]], Tuple[Dict[KT, VT_co]]]: ... |
50 | 40 | def __len__(self) -> int: ...
|
51 | 41 | def __eq__(self, other: Any) -> bool: ...
|
52 | 42 | @overload
|
53 |
| - def update(self, **kw: V) -> Map[str, V]: ... |
54 |
| - @overload |
55 | 43 | def update(
|
56 |
| - self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]], **kw: V |
57 |
| - ) -> Map[K, V]: ... |
58 |
| - def mutate(self) -> MapMutation[K, V]: ... |
59 |
| - def set(self, key: K, val: V) -> Map[K, V]: ... |
60 |
| - def delete(self, key: K) -> Map[K, V]: ... |
61 |
| - def get(self, key: K, default: D = ...) -> Union[V, D]: ... |
62 |
| - def __getitem__(self, key: K) -> V: ... |
63 |
| - def __contains__(self, key: object) -> bool: ... |
64 |
| - def __iter__(self) -> Iterator[K]: ... |
65 |
| - def keys(self) -> MapKeys[K]: ... |
66 |
| - def values(self) -> MapValues[V]: ... |
67 |
| - def items(self) -> MapItems[K, V]: ... |
68 |
| - def __hash__(self) -> int: ... |
69 |
| - def __dump__(self) -> str: ... |
70 |
| - def __class_getitem__(cls, item: Any) -> Type[Map]: ... |
71 |
| - |
72 |
| - |
73 |
| -S = TypeVar('S', bound='MapMutation') |
74 |
| - |
75 |
| - |
76 |
| -class MapMutation(MutableMapping[K, V]): |
77 |
| - def __init__(self, count: int, root: BitmapNode) -> None: ... |
78 |
| - def set(self, key: K, val: V) -> None: ... |
79 |
| - def __enter__(self: S) -> S: ... |
80 |
| - def __exit__(self, *exc: Any): ... |
81 |
| - def __iter__(self) -> NoReturn: ... |
82 |
| - def __delitem__(self, key: K) -> None: ... |
83 |
| - def __setitem__(self, key: K, val: V) -> None: ... |
84 |
| - def pop(self, __key: K, __default: D = ...) -> Union[V, D]: ... |
85 |
| - def get(self, key: K, default: D = ...) -> Union[V, D]: ... |
86 |
| - def __getitem__(self, key: K) -> V: ... |
87 |
| - def __contains__(self, key: Any) -> bool: ... |
| 44 | + self, |
| 45 | + __col: Union[IterableItems[KT, VT_co], Iterable[Tuple[KT, VT_co]]] |
| 46 | + ) -> Map[KT, VT_co]: ... |
88 | 47 | @overload
|
89 |
| - def update(self, **kw: V) -> None: ... |
| 48 | + def update( |
| 49 | + self: Map[Union[HT, str], Any], |
| 50 | + __col: Union[IterableItems[KT, VT_co], Iterable[Tuple[KT, VT_co]]], |
| 51 | + **kw: VT_co # type: ignore[misc] |
| 52 | + ) -> Map[KT, VT_co]: ... |
90 | 53 | @overload
|
91 | 54 | def update(
|
92 |
| - self, col: Union[Mapping[K, V], Iterable[Tuple[K, V]]], **kw: V |
93 |
| - ) -> None: ... |
94 |
| - def finish(self) -> Map[K, V]: ... |
95 |
| - def __len__(self) -> int: ... |
96 |
| - def __eq__(self, other: Any) -> bool: ... |
| 55 | + self: Map[Union[HT, str], Any], |
| 56 | + **kw: VT_co # type: ignore[misc] |
| 57 | + ) -> Map[KT, VT_co]: ... |
| 58 | + def mutate(self) -> MapMutation[KT, VT_co]: ... |
| 59 | + def set(self, key: KT, val: VT_co) -> Map[KT, VT_co]: ... # type: ignore[misc] |
| 60 | + def delete(self, key: KT) -> Map[KT, VT_co]: ... |
| 61 | + @overload |
| 62 | + def get(self, key: KT) -> Optional[VT_co]: ... |
| 63 | + @overload |
| 64 | + def get(self, key: KT, default: Union[VT_co, T]) -> Union[VT_co, T]: ... |
| 65 | + def __getitem__(self, key: KT) -> VT_co: ... |
| 66 | + def __contains__(self, key: Any) -> bool: ... |
| 67 | + def __iter__(self) -> Iterator[KT]: ... |
| 68 | + def keys(self) -> MapKeys[KT]: ... # type: ignore[override] |
| 69 | + def values(self) -> MapValues[VT_co]: ... # type: ignore[override] |
| 70 | + def items(self) -> MapItems[KT, VT_co]: ... # type: ignore[override] |
| 71 | + def __hash__(self) -> int: ... |
| 72 | + def __dump__(self) -> str: ... |
| 73 | + def __class_getitem__(cls, item: Any) -> Type[Map[Any, Any]]: ... |
0 commit comments