8000 Sync typeshed · python/mypy@cf221bd · GitHub
[go: up one dir, main page]

Skip to content

Commit cf221bd

Browse files
AlexWaygoodJelleZijlstra
authored andcommitted
Sync typeshed
Source commit: python/typeshed@ff7caa3
1 parent c591c89 commit cf221bd

File tree

143 files changed

+2703
-2458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2703
-2458
lines changed

mypy/typeshed/stdlib/_codecs.pyi

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ _CharMap: TypeAlias = dict[int, int] | _EncodingMap
1313
_Handler: TypeAlias = Callable[[UnicodeError], tuple[str | bytes, int]]
1414
_SearchFunction: TypeAlias = Callable[[str], codecs.CodecInfo | None]
1515

16-
def register(__search_function: _SearchFunction) -> None: ...
16+
def register(search_function: _SearchFunction, /) -> None: ...
1717

1818
if sys.version_info >= (3, 10):
19-
def unregister(__search_function: _SearchFunction) -> None: ...
19+
def unregister(search_function: _SearchFunction, /) -> None: ...
2020

21-
def register_error(__errors: str, __handler: _Handler) -> None: ...
22-
def lookup_error(__name: str) -> _Handler: ...
21+
def register_error(errors: str, handler: _Handler, /) -> None: ...
22+
def lookup_error(name: str, /) -> _Handler: ...
2323

2424
# The type ignore on `encode` and `decode` is to avoid issues with overlapping overloads, for more details, see #300
2525
# https://docs.python.org/3/library/codecs.html#binary-transforms
@@ -68,66 +68,66 @@ def decode(
6868
def decode(obj: str, encoding: Literal["hex", "hex_codec"], errors: str = "strict") -> bytes: ...
6969
@overload
7070
def decode(obj: ReadableBuffer, encoding: str = "utf-8", errors: str = "strict") -> str: ...
71-
def lookup(__encoding: str) -> codecs.CodecInfo: ...
72-
def charmap_build(__map: str) -> _CharMap: ...
73-
def ascii_decode(__data: ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
74-
def ascii_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
75-
def charmap_decode(__data: ReadableBuffer, __errors: str | None = None, __mapping: _CharMap | None = None) -> tuple[str, int]: ...
76-
def charmap_encode(__str: str, __errors: str | None = None, __mapping: _CharMap | None = None) -> tuple[bytes, int]: ...
77-
def escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
78-
def escape_encode(__data: bytes, __errors: str | None = None) -> tuple[bytes, int]: ...
79-
def latin_1_decode(__data: ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
80-
def latin_1_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
71+
def lookup(encoding: str, /) -> codecs.CodecInfo: ...
72+
def charmap_build(map: str, /) -> _CharMap: ...
73+
def ascii_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
74+
def ascii_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
75+
def charmap_decode(data: ReadableBuffer, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[str, int]: ...
76+
def charmap_encode(str: str, errors: str | None = None, mapping: _CharMap | None = None, /) -> tuple[bytes, int]: ...
77+
def escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
78+
def escape_encode(data: bytes, errors: str | None = None, /) -> tuple[bytes, int]: ...
79+
def latin_1_decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
80+
def latin_1_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
8181

8282
if sys.version_info >= (3, 9):
8383
def raw_unicode_escape_decode(
84-
__data: str | ReadableBuffer, __errors: str | None = None, __final: bool = True
84+
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
8585
) -> tuple[str, int]: ...
8686

8787
else:
88-
def raw_unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
88+
def raw_unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
8989

90-
def raw_unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
91-
def readbuffer_encode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[bytes, int]: ...
90+
def raw_unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
91+
def readbuffer_encode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[bytes, int]: ...
9292

9393
if sys.version_info >= (3, 9):
9494
def unicode_escape_decode(
95-
__data: str | ReadableBuffer, __errors: str | None = None, __final: bool = True
95+
data: str | ReadableBuffer, errors: str | None = None, final: bool = True, /
9696
) -> tuple[str, int]: ...
9797

9898
else:
99-
def unicode_escape_decode(__data: str | ReadableBuffer, __errors: str | None = None) -> tuple[str, int]: ...
99+
def unicode_escape_decode(data: str | ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ...
100100

101-
def unicode_escape_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
102-
def utf_16_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
103-
def utf_16_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
104-
def utf_16_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
105-
def utf_16_encode(__str: str, __errors: str | None = None, __byteorder: int = 0) -> tuple[bytes, int]: ...
101+
def unicode_escape_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
102+
def utf_16_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
103+
def utf_16_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
104+
def utf_16_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
105+
def utf_16_encode(str: str, errors: str | None = None, byteorder: int = 0, /) -> tuple[bytes, int]: ...
106106
def utf_16_ex_decode(
107-
__data: ReadableBuffer, __errors: str | None = None, __byteorder: int = 0, __final: bool = False
107+
data: ReadableBuffer, errors: str | None = None, byteorder: int = 0, final: bool = False, /
108108
) -> tuple[str, int, int]: ...
109-
def utf_16_le_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
110-
def utf_16_le_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
111-
def utf_32_be_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
112-
def utf_32_be_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
113-
def utf_32_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
114-
def utf_32_encode(__str: str, __errors: str | None = None, __byteorder: int = 0) -> tuple[bytes, int]: ...
109+
def utf_16_le_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
110+
def utf_16_le_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
111+
def utf_32_be_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
112+
def utf_32_be_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
113+
def utf_32_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
114+
def utf_32_encode(str: str, errors: str | None = None, byteorder: int = 0, /) -> tuple[bytes, int]: ...
115115
def utf_32_ex_decode(
116-
__data: ReadableBuffer, __errors: str | None = None, __byteorder: int = 0, __final: bool = False
116+
data: ReadableBuffer, errors: str | None = None, byteorder: int = 0, final: bool = False, /
117117
) -> tuple[str, int, int]: ...
118-
def utf_32_le_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
119-
def utf_32_le_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
120-
def utf_7_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
121-
def utf_7_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
122-
def utf_8_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
123-
def utf_8_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
118+
def utf_32_le_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
119+
def utf_32_le_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
120+
def utf_7_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
121+
def utf_7_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
122+
def utf_8_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
123+
def utf_8_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
124124

125125
if sys.platform == "win32":
126-
def mbcs_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
127-
def mbcs_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
126+
def mbcs_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
127+
def mbcs_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
128128
def code_page_decode(
129-
__codepage: int, __data: ReadableBuffer, __errors: str | None = None, __final: bool = False
129+
codepage: int, data: ReadableBuffer, errors: str | None = None, final: bool = False, /
130130
) -> tuple[str, int]: ...
131-
def code_page_encode(__code_page: int, __str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
132-
def oem_decode(__data: ReadableBuffer, __errors: str | None = None, __final: bool = False) -> tuple[str, int]: ...
133-
def oem_encode(__str: str, __errors: str | None = None) -> tuple[bytes, int]: ...
131+
def code_page_encode(code_page: int, str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...
132+
def oem_decode(data: ReadableBuffer, errors: str | None = None, final: bool = False, /) -> tuple[str, int]: ...
133+
def oem_encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ...

mypy/typeshed/stdlib/_collections_abc.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ _VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
6969

7070
@final
7171
class dict_keys(KeysView[_KT_co], Generic[_KT_co, _VT_co]): # undocumented
72-
def __eq__(self, __value: object) -> bool: ...
72+
def __eq__(self, value: object, /) -> bool: ...
7373
if sys.version_info >= (3, 10):
7474
@property
7575
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
@@ -82,7 +82,7 @@ class dict_values(ValuesView[_VT_co], Generic[_KT_co, _VT_co]): # undocumented
8282

8383
@final
8484
class dict_items(ItemsView[_KT_co, _VT_co]): # undocumented
85-
def __eq__(self, __value: object) -> bool: ...
85+
def __eq__(self, value: object, /) -> bool: ...
8686
if sys.version_info >= (3, 10):
8787
@property
8888
def mapping(self) -> MappingProxyType[_KT_co, _VT_co]: ...
@@ -91,4 +91,4 @@ if sys.version_info >= (3, 12):
9191
@runtime_checkable
9292
class Buffer(Protocol):
9393
@abstractmethod
94-
def __buffer__(self, __flags: int) -> memoryview: ...
94+
def __buffer__(self, flags: int, /) -> memoryview: ...

mypy/typeshed/stdlib/_compression.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ from typing import Any, Protocol
66
BUFFER_SIZE = DEFAULT_BUFFER_SIZE
77

88
class _Reader(Protocol):
9-
def read(self, __n: int) -> bytes: ...
9+
def read(self, n: int, /) -> bytes: ...
1010
def seekable(self) -> bool: ...
11-
def seek(self, __n: int) -> Any: ...
11+
def seek(self, n: int, /) -> Any: ...
1212

1313
class BaseStream(BufferedIOBase): ...
1414

mypy/typeshed/stdlib/_ctypes.pyi

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ if sys.platform == "win32":
4444
def FormatError(code: int = ...) -> str: ...
4545
def get_last_error() -> int: ...
4646
def set_last_error(value: int) -> int: ...
47-
def LoadLibrary(__name: str, __load_flags: int = 0) -> int: ...
48-
def FreeLibrary(__handle: int) -> None: ...
47+
def LoadLibrary(name: str, load_flags: int = 0, /) -> int: ...
48+
def FreeLibrary(handle: int, /) -> None: ...
4949

5050
class _CDataMeta(type):
5151
# By default mypy complains about the following two methods, because strictly speaking cls
@@ -75,8 +75,8 @@ class _CData(metaclass=_CDataMeta):
7575
def from_param(cls, obj: Any) -> Self | _CArgObject: ...
7676
@classmethod
7777
def in_dll(cls, library: CDLL, name: str) -> Self: ...
78-
def __buffer__(self, __flags: int) -> memoryview: ...
79-
def __release_buffer__(self, __buffer: memoryview) -> None: ...
78+
def __buffer__(self, flags: int, /) -> memoryview: ...
79+
def __release_buffer__(self, buffer: memoryview, /) -> None: ...
8080

8181
class _SimpleCData(_CData, Generic[_T]):
8282
value: _T
@@ -95,13 +95,13 @@ class _Pointer(_PointerLike, _CData, Generic[_CT]):
9595
@overload
9696
def __init__(self, arg: _CT) -> None: ...
9797
@overload
98-
def __getitem__(self, __key: int) -> Any: ...
98+
def __getitem__(self, key: int, /) -> Any: ...
9999
@overload
100-
def __getitem__(self, __key: slice) -> list[Any]: ...
101-
def __setitem__(self, __key: int, __value: Any) -> None: ...
100+
def __getitem__(self, key: slice, /) -> list[Any]: ...
101+
def __setitem__(self, key: int, value: Any, /) -> None: ...
102102

103103
def POINTER(type: type[_CT]) -> type[_Pointer[_CT]]: ...
104-
def pointer(__arg: _CT) -> _Pointer[_CT]: ...
104+
def pointer(arg: _CT, /) -> _Pointer[_CT]: ...
105105

106106
class _CArgObject: ...
107107

@@ -119,15 +119,15 @@ class CFuncPtr(_PointerLike, _CData):
119119
@overload
120120
def __init__(self) -> None: ...
121121
@overload
122-
def __init__(self, __address: int) -> None: ...
122+
def __init__(self, address: int, /) -> None: ...
123123
@overload
124-
def __init__(self, __callable: Callable[..., Any]) -> None: ...
124+
def __init__(self, callable: Callable[..., Any], /) -> None: ...
125125
@overload
126-
def __init__(self, __func_spec: tuple[str | int, CDLL], __paramflags: tuple[_PF, ...] | None = ...) -> None: ...
126+
def __init__(self, func_spec: tuple[str | int, CDLL], paramflags: tuple[_PF, ...] | None = ..., /) -> None: ...
127127
if sys.platform == "win32":
128128
@overload
129129
def __init__(
130-
self, __vtbl_index: int, __name: str, __paramflags: tuple[_PF, ...] | None = ..., __iid: _CData | None = ...
130+
self, vtbl_index: int, name: str, paramflags: tuple[_PF, ...] | None = ..., iid: _CData | None = ..., /
131131
) -> None: ...
132132

133133
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
@@ -139,10 +139,10 @@ class _CField(Generic[_CT, _GetT, _SetT]):
139139
offset: int
140140
size: int
141141
@overload
142-
def __get__(self, __instance: None, __owner: type[Any] | None) -> Self: ...
142+
def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ...
143143
@overload
144-
def __get__(self, __instance: Any, __owner: type[Any] | None) -> _GetT: ...
145-
def __set__(self, __instance: Any, __value: _SetT) -> None: ...
144+
def __get__(self, instance: Any, owner: type[Any] | None, /) -> _GetT: ...
145+
def __set__(self, instance: Any, value: _SetT, /) -> None: ...
146146

147147
class _StructUnionMeta(_CDataMeta):
148148
_fields_: Sequence[tuple[str, type[_CData]] | tuple[str, type[_CData], int]]
@@ -169,7 +169,11 @@ class Array(_CData, Generic[_CT]):
169169
def _type_(self) -> type[_CT]: ...
170170
@_type_.setter
171171
def _type_(self, value: type[_CT]) -> None: ...
172-
raw: bytes # Note: only available if _CT == c_char
172+
# Note: only available if _CT == c_char
173+
@property
174+
def raw(self) -> bytes: ...
175+
@raw.setter
176+
def raw(self, value: ReadableBuffer) -> None: ...
173177
value: Any # Note: bytes if _CT == c_char, str if _CT == c_wchar, unavailable otherwise
174178
# TODO These methods cannot be annotated correctly at the moment.
175179
# All of these "Any"s stand for the array's element type, but it's not possible to use _CT
@@ -185,13 +189,13 @@ class Array(_CData, Generic[_CT]):
185189
# the array element type would belong are annotated with Any instead.
186190
def __init__(self, *args: Any) -> None: ...
187191
@overload
188-
def __getitem__(self, __key: int) -> Any: ...
192+
def __getitem__(self, key: int, /) -> Any: ...
189193
@overload
190-
def __getitem__(self, __key: slice) -> list[Any]: ...
194+
def __getitem__(self, key: slice, /) -> list[Any]: ...
191195
@overload
192-
def __setitem__(self, __key: int, __value: Any) -> None: ...
196+
def __setitem__(self, key: int, value: Any, /) -> None: ...
193197
@overload
194-
def __setitem__(self, __key: slice, __value: Iterable[Any]) -> None: ...
198+
def __setitem__(self, key: slice, value: Iterable[Any], /) -> None: ...
195199
def __iter__(self) -> Iterator[Any]: ...
196200
# Can't inherit from Sized because the metaclass conflict between
197201
# Sized and _CData prevents using _CDataMeta.

0 commit comments

Comments
 (0)
0