|
| 1 | +# These stubs are forked from typeshed, since we use some definitions that only make |
| 2 | +# sense in the context of mypy/mypyc (in particular, native int types such as i64). |
| 3 | + |
1 | 4 | import abc
|
2 | 5 | import sys
|
3 | 6 | from _collections_abc import dict_items, dict_keys, dict_values
|
4 | 7 | from _typeshed import IdentityFunction, Self
|
5 | 8 | from collections.abc import Mapping
|
6 |
| -from typing import Any, ClassVar, Generic, TypeVar, overload, type_check_only |
7 |
| -from typing_extensions import Never |
| 9 | +from typing import Any, ClassVar, Generic, SupportsInt, TypeVar, overload, type_check_only |
| 10 | +from typing_extensions import Never, SupportsIndex |
| 11 | +from _typeshed import ReadableBuffer, SupportsTrunc |
8 | 12 |
|
9 | 13 | _T = TypeVar("_T")
|
10 | 14 | _U = TypeVar("_U")
|
@@ -68,3 +72,77 @@ def trait(cls: _T) -> _T: ...
|
68 | 72 | def mypyc_attr(*attrs: str, **kwattrs: object) -> IdentityFunction: ...
|
69 | 73 |
|
70 | 74 | class FlexibleAlias(Generic[_T, _U]): ...
|
| 75 | + |
| 76 | +# Native int types such as i64 are magical and support implicit |
| 77 | +# coercions to/from int using special logic in mypy. We generally only |
| 78 | +# include operations here for which we have specialized primitives. |
| 79 | + |
| 80 | +class i64: |
| 81 | + @overload |
| 82 | + def __new__(cls, __x: str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> i64: ... |
| 83 | + @overload |
| 84 | + def __new__(cls, __x: str | bytes | bytearray, base: SupportsIndex) -> i64: ... |
| 85 | + |
| 86 | + def __add__(self, x: i64) -> i64: ... |
| 87 | + def __radd__(self, x: i64) -> i64: ... |
| 88 | + def __sub__(self, x: i64) -> i64: ... |
| 89 | + def __rsub__(self, x: i64) -> i64: ... |
| 90 | + def __mul__(self, x: i64) -> i64: ... |
| 91 | + def __rmul__(self, x: i64) -> i64: ... |
| 92 | + def __floordiv__(self, x: i64) -> i64: ... |
| 93 | + def __rfloordiv__(self, x: i64) -> i64: ... |
| 94 | + def __mod__(self, x: i64) -> i64: ... |
| 95 | + def __rmod__(self, x: i64) -> i64: ... |
| 96 | + def __and__(self, x: i64) -> i64: ... |
| 97 | + def __rand__(self, x: i64) -> i64: ... |
| 98 | + def __or__(self, x: i64) -> i64: ... |
| 99 | + def __ror__(self, x: i64) -> i64: ... |
| 100 | + def __xor__(self, x: i64) -> i64: ... |
| 101 | + def __rxor__(self, x: i64) -> i64: ... |
| 102 | + def __lshift__(self, x: i64) -> i64: ... |
| 103 | + def __rlshift__(self, x: i64) -> i64: ... |
| 104 | + def __rshift__(self, x: i64) -> i64: ... |
| 105 | + def __rrshift__(self, x: i64) -> i64: ... |
| 106 | + def __neg__(self) -> i64: ... |
| 107 | + def __invert__(self) -> i64: ... |
| 108 | + def __pos__(self) -> i64: ... |
| 109 | + def __lt__(self, x: i64) -> bool: ... |
| 110 | + def __le__(self, x: i64) -> bool: ... |
| 111 | + def __ge__(self, x: i64) -> bool: ... |
| 112 | + def __gt__(self, x: i64) -> bool: ... |
| 113 | + def __index__(self) -> int: ... |
| 114 | + |
| 115 | +class i32: |
| 116 | + @overload |
| 117 | + def __new__(cls, __x: str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> i32: ... |
| 118 | + @overload |
| 119 | + def __new__(cls, __x: str | bytes | bytearray, base: SupportsIndex) -> i32: ... |
| 120 | + |
| 121 | + def __add__(self, x: i32) -> i32: ... |
| 122 | + def __radd__(self, x: i32) -> i32: ... |
| 123 | + def __sub__(self, x: i32) -> i32: ... |
| 124 | + def __rsub__(self, x: i32) -> i32: ... |
| 125 | + def __mul__(self, x: i32) -> i32: ... |
| 126 | + def __rmul__(self, x: i32) -> i32: ... |
| 127 | + def __floordiv__(self, x: i32) -> i32: ... |
| 128 | + def __rfloordiv__(self, x: i32) -> i32: ... |
| 129 | + def __mod__(self, x: i32) -> i32: ... |
| 130 | + def __rmod__(self, x: i32) -> i32: ... |
| 131 | + def __and__(self, x: i32) -> i32: ... |
| 132 | + def __rand__(self, x: i32) -> i32: ... |
| 133 | + def __or__(self, x: i32) -> i32: ... |
| 134 | + def __ror__(self, x: i32) -> i32: ... |
| 135 | + def __xor__(self, x: i32) -> i32: ... |
| 136 | + def __rxor__(self, x: i32) -> i32: ... |
| 137 | + def __lshift__(self, x: i32) -> i32: ... |
| 138 | + def __rlshift__(self, x: i32) -> i32: ... |
| 139 | + def __rshift__(self, x: i32) -> i32: ... |
| 140 | + def __rrshift__(self, x: i32) -> i32: ... |
| 141 | + def __neg__(self) -> i32: ... |
| 142 | + def __invert__(self) -> i32: ... |
| 143 | + def __pos__(self) -> i32: ... |
| 144 | + def __lt__(self, x: i32) -> bool: ... |
| 145 | + def __le__(self, x: i32) -> bool: ... |
| 146 | + def __ge__(self, x: i32) -> bool: ... |
| 147 | + def __gt__(self, x: i32) -> bool: ... |
| 148 | + def __index__(self) -> int: ... |
0 commit comments