Debian Codegraph @

test-data/unit/fixtures/dict.pyi

raw
1 # Builtins stub used in dictionary-related test cases (stripped down).
2 #
3 # NOTE: Use dict-full.pyi if you need more builtins instead of adding here,
4 # if feasible.
5
6 from _typeshed import SupportsKeysAndGetItem
7 import _typeshed
8 from typing import (
9 TypeVar, Generic, Iterable, Iterator, Mapping, Tuple, overload, Optional, Union, Sequence,
10 Self,
11 )
12
13 T = TypeVar('T')
14 T2 = TypeVar('T2')
15 KT = TypeVar('KT')
16 VT = TypeVar('VT')
17
18 class object:
19 def __init__(self) -> None: pass
20 def __eq__(self, other: object) -> bool: pass
21
22 class type: pass
23
24 class dict(Mapping[KT, VT]):
25 @overload
26 def __init__(self, **kwargs: VT) -> None: pass
27 @overload
28 def __init__(self, arg: Iterable[Tuple[KT, VT]], **kwargs: VT) -> None: pass
29 def __getitem__(self, key: KT) -> VT: pass
30 def __setitem__(self, k: KT, v: VT) -> None: pass
31 def __iter__(self) -> Iterator[KT]: pass
32 def __contains__(self, item: object) -> int: pass
33 def update(self, a: SupportsKeysAndGetItem[KT, VT]) -> None: pass
34 @overload
35 def get(self, key: KT, default: None = None, /) -> Optional[VT]: pass
36 @overload
37 def get(self, key: KT, default: VT, /) -> VT: pass
38 @overload
39 def get(self, key: KT, default: T, /) -> Union[VT, T]: pass
40 def __len__(self) -> int: ...
41
42 class int: # for convenience
43 def __add__(self, x: Union[int, complex]) -> int: pass
44 def __radd__(self, x: int) -> int: pass
45 def __sub__(self, x: Union[int, complex]) -> int: pass
46
47 class str: pass # for keyword argument key type
48 class bytes: pass
49
50 class list(Sequence[T]): # needed by some test cases
51 def __getitem__(self, x: int) -> T: pass
52 def __iter__(self) -> Iterator[T]: pass
53 def __mul__(self, x: int) -> list[T]: pass
54 def __contains__(self, item: object) -> bool: pass
55 def append(self, item: T) -> None: pass
56
57 class tuple(Generic[T]): pass
58 class function: pass
59 class float: pass
60 class complex: pass
61 class bool(int): pass
62 class ellipsis: pass
63 class BaseException: pass
64
65 def isinstance(x: object, t: Union[type, Tuple[type, ...]]) -> bool: pass
66 def iter(__iterable: Iterable[T]) -> Iterator[T]: pass