Skip to content

Sync typeshed #11712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mypy/typeshed/stdlib/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ _compression: 3.6-
_csv: 2.7-
_curses: 2.7-
_decimal: 3.6-
_dummy_thread: 3.6-
_dummy_threading: 2.7-
_dummy_thread: 3.6-3.8
_dummy_threading: 2.7-3.8
_heapq: 2.7-
_imp: 3.6-
_json: 2.7-
Expand Down Expand Up @@ -103,8 +103,9 @@ decimal: 2.7-
difflib: 2.7-
dis: 2.7-
distutils: 2.7-
distutils.command.bdist_msi: 2.7-3.10
doctest: 2.7-
dummy_threading: 2.7-
dummy_threading: 2.7-3.8
email: 2.7-
encodings: 2.7-
ensurepip: 2.7-
Expand Down Expand Up @@ -138,6 +139,7 @@ imghdr: 2.7-
imp: 2.7-
importlib: 2.7-
importlib.metadata: 3.8-
importlib.metadata._meta: 3.10-
importlib.resources: 3.7-
inspect: 2.7-
io: 2.7-
Expand Down Expand Up @@ -259,6 +261,7 @@ typing: 3.5-
typing_extensions: 2.7-
unicodedata: 2.7-
unittest: 2.7-
unittest._log: 3.9-
urllib: 2.7-
uu: 2.7-
uuid: 2.7-
Expand Down
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/_csv.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class _writer:
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...

class _Writer(Protocol):
def write(self, s: str) -> Any: ...
def write(self, __s: str) -> object: ...

def writer(csvfile: _Writer, dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ...
def reader(csvfile: Iterable[str], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ...
Expand Down
16 changes: 8 additions & 8 deletions mypy/typeshed/stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ class _CursesWindow:
def getmaxyx(self) -> tuple[int, int]: ...
def getparyx(self) -> tuple[int, int]: ...
@overload
def getstr(self) -> _chtype: ...
def getstr(self) -> bytes: ...
@overload
def getstr(self, n: int) -> _chtype: ...
def getstr(self, n: int) -> bytes: ...
@overload
def getstr(self, y: int, x: int) -> _chtype: ...
def getstr(self, y: int, x: int) -> bytes: ...
@overload
def getstr(self, y: int, x: int, n: int) -> _chtype: ...
def getstr(self, y: int, x: int, n: int) -> bytes: ...
def getyx(self) -> tuple[int, int]: ...
@overload
def hline(self, ch: _chtype, n: int) -> None: ...
Expand All @@ -460,9 +460,9 @@ class _CursesWindow:
def idlok(self, yes: bool) -> None: ...
def immedok(self, flag: bool) -> None: ...
@overload
def inch(self) -> _chtype: ...
def inch(self) -> int: ...
@overload
def inch(self, y: int, x: int) -> _chtype: ...
def inch(self, y: int, x: int) -> int: ...
@overload
def insch(self, ch: _chtype, attr: int = ...) -> None: ...
@overload
Expand All @@ -478,9 +478,9 @@ class _CursesWindow:
@overload
def insstr(self, y: int, x: int, str: str, attr: int = ...) -> None: ...
@overload
def instr(self, n: int = ...) -> _chtype: ...
def instr(self, n: int = ...) -> bytes: ...
@overload
def instr(self, y: int, x: int, n: int = ...) -> _chtype: ...
def instr(self, y: int, x: int, n: int = ...) -> bytes: ...
def is_linetouched(self, __line: int) -> bool: ...
def is_wintouched(self) -> bool: ...
def keypad(self, yes: bool) -> None: ...
Expand Down
16 changes: 8 additions & 8 deletions mypy/typeshed/stdlib/_msi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ if sys.platform == "win32":
def Modify(self, mode: int, record: _Record) -> None: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Summary, not exposed by the implementation
class _Summary:
def GetProperty(self, propid: int) -> str | bytes | None: ...
def GetPropertyCount(self) -> int: ...
def SetProperty(self, propid: int, value: str | bytes) -> None: ...
def Persist(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Database, not exposed by the implementation
class _Database:
def OpenView(self, sql: str) -> _View: ...
def Commit(self) -> None: ...
def GetSummaryInformation(self, updateCount: int) -> _Summary: ...
def Close(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
# Actual typename Record, not exposed by the implementation
class _Record:
def GetFieldCount(self) -> int: ...
Expand All @@ -40,8 +40,8 @@ if sys.platform == "win32":
def SetInteger(self, field: int, int: int) -> None: ...
def ClearData(self) -> None: ...
# Don't exist at runtime
__new__: None # type: ignore
__init__: None # type: ignore
__new__: None # type: ignore[assignment]
__init__: None # type: ignore[assignment]
def UuidCreate() -> str: ...
def FCICreate(cabname: str, files: list[str]) -> None: ...
def OpenDatabase(name: str, flags: int) -> _Database: ...
Expand Down
212 changes: 155 additions & 57 deletions mypy/typeshed/stdlib/_operator.pyi
Original file line number Diff line number Diff line change
@@ -1,60 +1,158 @@
# In reality the import is the other way around, but this way we can keep the operator stub in 2and3
from operator import (
abs as abs,
add as add,
and_ as and_,
attrgetter as attrgetter,
concat as concat,
contains as contains,
countOf as countOf,
delitem as delitem,
eq as eq,
floordiv as floordiv,
ge as ge,
getitem as getitem,
gt as gt,
iadd as iadd,
iand as iand,
iconcat as iconcat,
ifloordiv as ifloordiv,
ilshift as ilshift,
imatmul as imatmul,
imod as imod,
imul as imul,
index as index,
indexOf as indexOf,
inv as inv,
invert as invert,
ior as ior,
ipow as ipow,
irshift as irshift,
is_ as is_,
is_not as is_not,
isub as isub,
itemgetter as itemgetter,
itruediv as itruediv,
ixor as ixor,
le as le,
length_hint as length_hint,
lshift as lshift,
lt as lt,
matmul as matmul,
methodcaller as methodcaller,
mod as mod,
mul as mul,
ne as ne,
neg as neg,
not_ as not_,
or_ as or_,
pos as pos,
pow as pow,
rshift as rshift,
setitem as setitem,
sub as sub,
truediv as truediv,
truth as truth,
xor as xor,
import sys
from typing import (
Any,
AnyStr,
Callable,
Container,
Generic,
Iterable,
Mapping,
MutableMapping,
MutableSequence,
Protocol,
Sequence,
SupportsAbs,
Tuple,
TypeVar,
Union,
overload,
)
from typing import AnyStr
from typing_extensions import ParamSpec, SupportsIndex, final

_R = TypeVar("_R")
_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
_K = TypeVar("_K")
_V = TypeVar("_V")
_P = ParamSpec("_P")

class _SupportsInversion(Protocol[_T_co]):
def __invert__(self) -> _T_co: ...

class _SupportsNeg(Protocol[_T_co]):
def __neg__(self) -> _T_co: ...

class _SupportsPos(Protocol[_T_co]):
def __pos__(self) -> _T_co: ...

# Different to _typeshed.SupportsLessThan
class _SupportsLT(Protocol):
def __lt__(self, __other: Any) -> Any: ...

class _SupportsGT(Protocol):
def __gt__(self, __other: Any) -> Any: ...

class _SupportsLE(Protocol):
def __le__(self, __other: Any) -> Any: ...

class _SupportsGE(Protocol):
def __ge__(self, __other: Any) -> Any: ...

# We get false-positive errors if e.g. `lt` does not have the same signature as `le`,
# so a broad union type is required for all four comparison methods
_SupportsComparison = Union[_SupportsLE, _SupportsGE, _SupportsGT, _SupportsLT]

def lt(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ...
def le(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ...
def eq(__a: object, __b: object) -> Any: ...
def ne(__a: object, __b: object) -> Any: ...
def ge(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ...
def gt(__a: _SupportsComparison, __b: _SupportsComparison) -> Any: ...
def not_(__a: object) -> bool: ...
def truth(__a: object) -> bool: ...
def is_(__a: object, __b: object) -> bool: ...
def is_not(__a: object, __b: object) -> bool: ...
def abs(__a: SupportsAbs[_T]) -> _T: ...
def add(__a: Any, __b: Any) -> Any: ...
def and_(__a: Any, __b: Any) -> Any: ...
def floordiv(__a: Any, __b: Any) -> Any: ...
def index(__a: SupportsIndex) -> int: ...
def inv(__a: _SupportsInversion[_T_co]) -> _T_co: ...
def invert(__a: _SupportsInversion[_T_co]) -> _T_co: ...
def lshift(__a: Any, __b: Any) -> Any: ...
def mod(__a: Any, __b: Any) -> Any: ...
def mul(__a: Any, __b: Any) -> Any: ...
def matmul(__a: Any, __b: Any) -> Any: ...
def neg(__a: _SupportsNeg[_T_co]) -> _T_co: ...
def or_(__a: Any, __b: Any) -> Any: ...
def pos(__a: _SupportsPos[_T_co]) -> _T_co: ...
def pow(__a: Any, __b: Any) -> Any: ...
def rshift(__a: Any, __b: Any) -> Any: ...
def sub(__a: Any, __b: Any) -> Any: ...
def truediv(__a: Any, __b: Any) -> Any: ...
def xor(__a: Any, __b: Any) -> Any: ...
def concat(__a: Sequence[_T], __b: Sequence[_T]) -> Sequence[_T]: ...
def contains(__a: Container[object], __b: object) -> bool: ...
def countOf(__a: Iterable[object], __b: object) -> int: ...
@overload
def delitem(__a: MutableSequence[Any], __b: SupportsIndex) -> None: ...
@overload
def delitem(__a: MutableSequence[Any], __b: slice) -> None: ...
@overload
def delitem(__a: MutableMapping[_K, Any], __b: _K) -> None: ...
@overload
def getitem(__a: Sequence[_T], __b: SupportsIndex) -> _T: ...
@overload
def getitem(__a: Sequence[_T], __b: slice) -> Sequence[_T]: ...
@overload
def getitem(__a: Mapping[_K, _V], __b: _K) -> _V: ...
def indexOf(__a: Iterable[_T], __b: _T) -> int: ...
@overload
def setitem(__a: MutableSequence[_T], __b: SupportsIndex, __c: _T) -> None: ...
@overload
def setitem(__a: MutableSequence[_T], __b: slice, __c: Sequence[_T]) -> None: ...
@overload
def setitem(__a: MutableMapping[_K, _V], __b: _K, __c: _V) -> None: ...
def length_hint(__obj: object, __default: int = ...) -> int: ...
@final
class attrgetter(Generic[_T_co]):
@overload
def __new__(cls, attr: str) -> attrgetter[Any]: ...
@overload
def __new__(cls, attr: str, __attr2: str) -> attrgetter[tuple[Any, Any]]: ...
@overload
def __new__(cls, attr: str, __attr2: str, __attr3: str) -> attrgetter[tuple[Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, __attr2: str, __attr3: str, __attr4: str) -> attrgetter[tuple[Any, Any, Any, Any]]: ...
@overload
def __new__(cls, attr: str, *attrs: str) -> attrgetter[Tuple[Any, ...]]: ...
def __call__(self, obj: Any) -> _T_co: ...

@final
class itemgetter(Generic[_T_co]):
@overload
def __new__(cls, item: Any) -> itemgetter[Any]: ...
@overload
def __new__(cls, item: Any, __item2: Any) -> itemgetter[tuple[Any, Any]]: ...
@overload
def __new__(cls, item: Any, __item2: Any, __item3: Any) -> itemgetter[tuple[Any, Any, Any]]: ...
@overload
def __new__(cls, item: Any, __item2: Any, __item3: Any, __item4: Any) -> itemgetter[tuple[Any, Any, Any, Any]]: ...
@overload
def __new__(cls, item: Any, *items: Any) -> itemgetter[Tuple[Any, ...]]: ...
def __call__(self, obj: Any) -> _T_co: ...

@final
class methodcaller:
def __init__(self, __name: str, *args: Any, **kwargs: Any) -> None: ...
def __call__(self, obj: Any) -> Any: ...

def iadd(__a: Any, __b: Any) -> Any: ...
def iand(__a: Any, __b: Any) -> Any: ...
def iconcat(__a: Any, __b: Any) -> Any: ...
def ifloordiv(__a: Any, __b: Any) -> Any: ...
def ilshift(__a: Any, __b: Any) -> Any: ...
def imod(__a: Any, __b: Any) -> Any: ...
def imul(__a: Any, __b: Any) -> Any: ...
def imatmul(__a: Any, __b: Any) -> Any: ...
def ior(__a: Any, __b: Any) -> Any: ...
def ipow(__a: Any, __b: Any) -> Any: ...
def irshift(__a: Any, __b: Any) -> Any: ...
def isub(__a: Any, __b: Any) -> Any: ...
def itruediv(__a: Any, __b: Any) -> Any: ...
def ixor(__a: Any, __b: Any) -> Any: ...

if sys.version_info >= (3, 11):
def call(__obj: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> _R: ... # type: ignore

def _compare_digest(__a: AnyStr, __b: AnyStr) -> bool: ...
9 changes: 8 additions & 1 deletion mypy/typeshed/stdlib/_osx_support.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import Iterable, Sequence, Tuple, TypeVar

_T = TypeVar("_T")
Expand All @@ -11,7 +12,13 @@ _COMPILER_CONFIG_VARS: Tuple[str, ...] # undocumented
_INITPRE: str # undocumented

def _find_executable(executable: str, path: str | None = ...) -> str | None: ... # undocumented
def _read_output(commandstring: str) -> str | None: ... # undocumented

if sys.version_info >= (3, 7):
def _read_output(commandstring: str, capture_stderr: bool = ...) -> str | None: ... # undocumented

else:
def _read_output(commandstring: str) -> str | None: ... # undocumented

def _find_build_tool(toolname: str) -> str: ... # undocumented

_SYSTEM_VERSION: str | None # undocumented
Expand Down
4 changes: 3 additions & 1 deletion mypy/typeshed/stdlib/_tkinter.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import Any
from typing_extensions import Literal, final

Expand Down Expand Up @@ -68,7 +69,8 @@ class TkappType:
quit: Any
record: Any
setvar: Any
split: Any
if sys.version_info < (3, 11):
split: Any
splitlist: Any
unsetvar: Any
wantobjects: Any
Expand Down
1 change: 1 addition & 0 deletions mypy/typeshed/stdlib/_weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _T = TypeVar("_T")
@final
class CallableProxyType(Generic[_C]): # "weakcallableproxy"
def __getattr__(self, attr: str) -> Any: ...
__call__: _C

@final
class ProxyType(Generic[_T]): # "weakproxy"
Expand Down
Loading