Skip to content

Commit e266cdf

Browse files
authored
Sync typeshed (#11905)
Source commit: python/typeshed@9116b29 * Fix self check * update testDictWithStarStarSpecialCase * update testTypedDictMappingMethods * xfail testAsyncioGatherPreciseType Co-authored-by: hauntsaninja <>
1 parent b36d8cf commit e266cdf

File tree

281 files changed

+6083
-4685
lines changed

Some content is hidden

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

281 files changed

+6083
-4685
lines changed

mypy/fscache.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,13 @@ def _fake_init(self, path: str) -> os.stat_result:
143143
assert not os.path.exists(path), path # Not cached!
144144
dirname = os.path.normpath(dirname)
145145
st = self.stat(dirname) # May raise OSError
146-
# Get stat result as a sequence so we can modify it.
147-
# (Alas, typeshed's os.stat_result is not a sequence yet.)
148-
tpl = tuple(st) # type: ignore[arg-type, var-annotated]
149-
seq: List[float] = list(tpl)
146+
# Get stat result as a list so we can modify it.
147+
seq: List[float] = list(st)
150148
seq[stat.ST_MODE] = stat.S_IFREG | 0o444
151149
seq[stat.ST_INO] = 1
152150
seq[stat.ST_NLINK] = 1
153151
seq[stat.ST_SIZE] = 0
154-
tpl = tuple(seq)
155-
st = os.stat_result(tpl)
152+
st = os.stat_result(seq)
156153
self.stat_cache[path] = st
157154
# Make listdir() and read() also pretend this file exists.
158155
self.fake_package_cache.add(dirname)

mypy/typeshed/stdlib/@python2/_typeshed/xml.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Stub-only types. This module does not exist at runtime.
22

3-
from typing import Any
4-
from typing_extensions import Protocol
3+
from typing import Any, Protocol
54

65
# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
76
class DOMImplementation(Protocol):
Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,96 @@
1+
import sys
12
from types import TracebackType
23
from typing import Any, Tuple, Type, Union
34

4-
_KeyType = Union[HKEYType, int]
5+
if sys.platform == "win32":
6+
_KeyType = Union[HKEYType, int]
7+
def CloseKey(__hkey: _KeyType) -> None: ...
8+
def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ...
9+
def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ...
10+
def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ...
11+
def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ...
12+
def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ...
13+
def DeleteValue(__key: _KeyType, __value: str) -> None: ...
14+
def EnumKey(__key: _KeyType, __index: int) -> str: ...
15+
def EnumValue(__key: _KeyType, __index: int) -> Tuple[str, Any, int]: ...
16+
def ExpandEnvironmentStrings(__str: str) -> str: ...
17+
def FlushKey(__key: _KeyType) -> None: ...
18+
def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ...
19+
def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
20+
def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
21+
def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ...
22+
def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ...
23+
def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ...
24+
def SaveKey(__key: _KeyType, __file_name: str) -> None: ...
25+
def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ...
26+
def SetValueEx(
27+
__key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int
28+
) -> None: ... # reserved is ignored
29+
def DisableReflectionKey(__key: _KeyType) -> None: ...
30+
def EnableReflectionKey(__key: _KeyType) -> None: ...
31+
def QueryReflectionKey(__key: _KeyType) -> bool: ...
32+
HKEY_CLASSES_ROOT: int
33+
HKEY_CURRENT_USER: int
34+
HKEY_LOCAL_MACHINE: int
35+
HKEY_USERS: int
36+
HKEY_PERFORMANCE_DATA: int
37+
HKEY_CURRENT_CONFIG: int
38+
HKEY_DYN_DATA: int
539

6-
def CloseKey(__hkey: _KeyType) -> None: ...
7-
def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ...
8-
def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ...
9-
def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ...
10-
def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ...
11-
def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ...
12-
def DeleteValue(__key: _KeyType, __value: str) -> None: ...
13-
def EnumKey(__key: _KeyType, __index: int) -> str: ...
14-
def EnumValue(__key: _KeyType, __index: int) -> Tuple[str, Any, int]: ...
15-
def ExpandEnvironmentStrings(__str: str) -> str: ...
16-
def FlushKey(__key: _KeyType) -> None: ...
17-
def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ...
18-
def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
19-
def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
20-
def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ...
21-
def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ...
22-
def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ...
23-
def SaveKey(__key: _KeyType, __file_name: str) -> None: ...
24-
def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ...
25-
def SetValueEx(
26-
__key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int
27-
) -> None: ... # reserved is ignored
28-
def DisableReflectionKey(__key: _KeyType) -> None: ...
29-
def EnableReflectionKey(__key: _KeyType) -> None: ...
30-
def QueryReflectionKey(__key: _KeyType) -> bool: ...
40+
KEY_ALL_ACCESS: int
41+
KEY_WRITE: int
42+
KEY_READ: int
43+
KEY_EXECUTE: int
44+
KEY_QUERY_VALUE: int
45+
KEY_SET_VALUE: int
46+
KEY_CREATE_SUB_KEY: int
47+
KEY_ENUMERATE_SUB_KEYS: int
48+
KEY_NOTIFY: int
49+
KEY_CREATE_LINK: int
3150

32-
HKEY_CLASSES_ROOT: int
33-
HKEY_CURRENT_USER: int
34-
HKEY_LOCAL_MACHINE: int
35-
HKEY_USERS: int
36-
HKEY_PERFORMANCE_DATA: int
37-
HKEY_CURRENT_CONFIG: int
38-
HKEY_DYN_DATA: int
51+
KEY_WOW64_64KEY: int
52+
KEY_WOW64_32KEY: int
3953

40-
KEY_ALL_ACCESS: int
41-
KEY_WRITE: int
42-
KEY_READ: int
43-
KEY_EXECUTE: int
44-
KEY_QUERY_VALUE: int
45-
KEY_SET_VALUE: int
46-
KEY_CREATE_SUB_KEY: int
47-
KEY_ENUMERATE_SUB_KEYS: int
48-
KEY_NOTIFY: int
49-
KEY_CREATE_LINK: int
54+
REG_BINARY: int
55+
REG_DWORD: int
56+
REG_DWORD_LITTLE_ENDIAN: int
57+
REG_DWORD_BIG_ENDIAN: int
58+
REG_EXPAND_SZ: int
59+
REG_LINK: int
60+
REG_MULTI_SZ: int
61+
REG_NONE: int
62+
REG_RESOURCE_LIST: int
63+
REG_FULL_RESOURCE_DESCRIPTOR: int
64+
REG_RESOURCE_REQUIREMENTS_LIST: int
65+
REG_SZ: int
5066

51-
KEY_WOW64_64KEY: int
52-
KEY_WOW64_32KEY: int
67+
REG_CREATED_NEW_KEY: int # undocumented
68+
REG_LEGAL_CHANGE_FILTER: int # undocumented
69+
REG_LEGAL_OPTION: int # undocumented
70+
REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented
71+
REG_NOTIFY_CHANGE_LAST_SET: int # undocumented
72+
REG_NOTIFY_CHANGE_NAME: int # undocumented
73+
REG_NOTIFY_CHANGE_SECURITY: int # undocumented
74+
REG_NO_LAZY_FLUSH: int # undocumented
75+
REG_OPENED_EXISTING_KEY: int # undocumented
76+
REG_OPTION_BACKUP_RESTORE: int # undocumented
77+
REG_OPTION_CREATE_LINK: int # undocumented
78+
REG_OPTION_NON_VOLATILE: int # undocumented
79+
REG_OPTION_OPEN_LINK: int # undocumented
80+
REG_OPTION_RESERVED: int # undocumented
81+
REG_OPTION_VOLATILE: int # undocumented
82+
REG_REFRESH_HIVE: int # undocumented
83+
REG_WHOLE_HIVE_VOLATILE: int # undocumented
5384

54-
REG_BINARY: int
55-
REG_DWORD: int
56-
REG_DWORD_LITTLE_ENDIAN: int
57-
REG_DWORD_BIG_ENDIAN: int
58-
REG_EXPAND_SZ: int
59-
REG_LINK: int
60-
REG_MULTI_SZ: int
61-
REG_NONE: int
62-
REG_RESOURCE_LIST: int
63-
REG_FULL_RESOURCE_DESCRIPTOR: int
64-
REG_RESOURCE_REQUIREMENTS_LIST: int
65-
REG_SZ: int
85+
error = OSError
6686

67-
REG_CREATED_NEW_KEY: int # undocumented
68-
REG_LEGAL_CHANGE_FILTER: int # undocumented
69-
REG_LEGAL_OPTION: int # undocumented
70-
REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented
71-
REG_NOTIFY_CHANGE_LAST_SET: int # undocumented
72-
REG_NOTIFY_CHANGE_NAME: int # undocumented
73-
REG_NOTIFY_CHANGE_SECURITY: int # undocumented
74-
REG_NO_LAZY_FLUSH: int # undocumented
75-
REG_OPENED_EXISTING_KEY: int # undocumented
76-
REG_OPTION_BACKUP_RESTORE: int # undocumented
77-
REG_OPTION_CREATE_LINK: int # undocumented
78-
REG_OPTION_NON_VOLATILE: int # undocumented
79-
REG_OPTION_OPEN_LINK: int # undocumented
80-
REG_OPTION_RESERVED: int # undocumented
81-
REG_OPTION_VOLATILE: int # undocumented
82-
REG_REFRESH_HIVE: int # undocumented
83-
REG_WHOLE_HIVE_VOLATILE: int # undocumented
84-
85-
error = OSError
86-
87-
# Though this class has a __name__ of PyHKEY, it's exposed as HKEYType for some reason
88-
class HKEYType:
89-
def __bool__(self) -> bool: ...
90-
def __int__(self) -> int: ...
91-
def __enter__(self) -> HKEYType: ...
92-
def __exit__(
93-
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
94-
) -> bool | None: ...
95-
def Close(self) -> None: ...
96-
def Detach(self) -> int: ...
87+
# Though this class has a __name__ of PyHKEY, it's exposed as HKEYType for some reason
88+
class HKEYType:
89+
def __bool__(self) -> bool: ...
90+
def __int__(self) -> int: ...
91+
def __enter__(self) -> HKEYType: ...
92+
def __exit__(
93+
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
94+
) -> bool | None: ...
95+
def Close(self) -> None: ...
96+
def Detach(self) -> int: ...

mypy/typeshed/stdlib/@python2/contextlib.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from types import TracebackType
2-
from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar
3-
from typing_extensions import Protocol
2+
from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Protocol, Type, TypeVar
43

54
_T = TypeVar("_T")
65
_T_co = TypeVar("_T_co", covariant=True)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
def crypt(word: str, salt: str) -> str: ...
1+
import sys
2+
3+
if sys.platform != "win32":
4+
def crypt(word: str, salt: str) -> str: ...

mypy/typeshed/stdlib/@python2/ctypes/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def create_unicode_buffer(init: _UnionT[int, Text], size: int | None = ...) -> A
150150
if sys.platform == "win32":
151151
def DllCanUnloadNow() -> int: ...
152152
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
153-
def FormatError(code: int) -> str: ...
153+
def FormatError(code: int = ...) -> str: ...
154154
def GetLastError() -> int: ...
155155

156156
def get_errno() -> int: ...
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
from distutils.cmd import Command
1+
import sys
22

3-
class bdist_msi(Command):
4-
def initialize_options(self) -> None: ...
5-
def finalize_options(self) -> None: ...
6-
def run(self) -> None: ...
3+
if sys.platform == "win32":
4+
from distutils.cmd import Command
5+
class bdist_msi(Command):
6+
def initialize_options(self) -> None: ...
7+
def finalize_options(self) -> None: ...
8+
def run(self) -> None: ...

0 commit comments

Comments
 (0)