Skip to content

Sync typeshed #11905

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

Merged
merged 6 commits into from
Jan 28, 2022
Merged
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: 3 additions & 6 deletions mypy/fscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,13 @@ def _fake_init(self, path: str) -> os.stat_result:
assert not os.path.exists(path), path # Not cached!
dirname = os.path.normpath(dirname)
st = self.stat(dirname) # May raise OSError
# Get stat result as a sequence so we can modify it.
# (Alas, typeshed's os.stat_result is not a sequence yet.)
tpl = tuple(st) # type: ignore[arg-type, var-annotated]
seq: List[float] = list(tpl)
# Get stat result as a list so we can modify it.
seq: List[float] = list(st)
seq[stat.ST_MODE] = stat.S_IFREG | 0o444
seq[stat.ST_INO] = 1
seq[stat.ST_NLINK] = 1
seq[stat.ST_SIZE] = 0
tpl = tuple(seq)
st = os.stat_result(tpl)
st = os.stat_result(seq)
self.stat_cache[path] = st
# Make listdir() and read() also pretend this file exists.
self.fake_package_cache.add(dirname)
Expand Down
3 changes: 1 addition & 2 deletions mypy/typeshed/stdlib/@python2/_typeshed/xml.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Stub-only types. This module does not exist at runtime.

from typing import Any
from typing_extensions import Protocol
from typing import Any, Protocol

# As defined https://docs.python.org/3/library/xml.dom.html#domimplementation-objects
class DOMImplementation(Protocol):
Expand Down
174 changes: 87 additions & 87 deletions mypy/typeshed/stdlib/@python2/_winreg.pyi
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
import sys
from types import TracebackType
from typing import Any, Tuple, Type, Union

_KeyType = Union[HKEYType, int]
if sys.platform == "win32":
_KeyType = Union[HKEYType, int]
def CloseKey(__hkey: _KeyType) -> None: ...
def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ...
def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ...
def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ...
def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ...
def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ...
def DeleteValue(__key: _KeyType, __value: str) -> None: ...
def EnumKey(__key: _KeyType, __index: int) -> str: ...
def EnumValue(__key: _KeyType, __index: int) -> Tuple[str, Any, int]: ...
def ExpandEnvironmentStrings(__str: str) -> str: ...
def FlushKey(__key: _KeyType) -> None: ...
def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ...
def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ...
def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ...
def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ...
def SaveKey(__key: _KeyType, __file_name: str) -> None: ...
def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ...
def SetValueEx(
__key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int
) -> None: ... # reserved is ignored
def DisableReflectionKey(__key: _KeyType) -> None: ...
def EnableReflectionKey(__key: _KeyType) -> None: ...
def QueryReflectionKey(__key: _KeyType) -> bool: ...
HKEY_CLASSES_ROOT: int
HKEY_CURRENT_USER: int
HKEY_LOCAL_MACHINE: int
HKEY_USERS: int
HKEY_PERFORMANCE_DATA: int
HKEY_CURRENT_CONFIG: int
HKEY_DYN_DATA: int

def CloseKey(__hkey: _KeyType) -> None: ...
def ConnectRegistry(__computer_name: str | None, __key: _KeyType) -> HKEYType: ...
def CreateKey(__key: _KeyType, __sub_key: str | None) -> HKEYType: ...
def CreateKeyEx(key: _KeyType, sub_key: str | None, reserved: int = ..., access: int = ...) -> HKEYType: ...
def DeleteKey(__key: _KeyType, __sub_key: str) -> None: ...
def DeleteKeyEx(key: _KeyType, sub_key: str, access: int = ..., reserved: int = ...) -> None: ...
def DeleteValue(__key: _KeyType, __value: str) -> None: ...
def EnumKey(__key: _KeyType, __index: int) -> str: ...
def EnumValue(__key: _KeyType, __index: int) -> Tuple[str, Any, int]: ...
def ExpandEnvironmentStrings(__str: str) -> str: ...
def FlushKey(__key: _KeyType) -> None: ...
def LoadKey(__key: _KeyType, __sub_key: str, __file_name: str) -> None: ...
def OpenKey(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
def OpenKeyEx(key: _KeyType, sub_key: str, reserved: int = ..., access: int = ...) -> HKEYType: ...
def QueryInfoKey(__key: _KeyType) -> Tuple[int, int, int]: ...
def QueryValue(__key: _KeyType, __sub_key: str | None) -> str: ...
def QueryValueEx(__key: _KeyType, __name: str) -> Tuple[Any, int]: ...
def SaveKey(__key: _KeyType, __file_name: str) -> None: ...
def SetValue(__key: _KeyType, __sub_key: str, __type: int, __value: str) -> None: ...
def SetValueEx(
__key: _KeyType, __value_name: str | None, __reserved: Any, __type: int, __value: str | int
) -> None: ... # reserved is ignored
def DisableReflectionKey(__key: _KeyType) -> None: ...
def EnableReflectionKey(__key: _KeyType) -> None: ...
def QueryReflectionKey(__key: _KeyType) -> bool: ...
KEY_ALL_ACCESS: int
KEY_WRITE: int
KEY_READ: int
KEY_EXECUTE: int
KEY_QUERY_VALUE: int
KEY_SET_VALUE: int
KEY_CREATE_SUB_KEY: int
KEY_ENUMERATE_SUB_KEYS: int
KEY_NOTIFY: int
KEY_CREATE_LINK: int

HKEY_CLASSES_ROOT: int
HKEY_CURRENT_USER: int
HKEY_LOCAL_MACHINE: int
HKEY_USERS: int
HKEY_PERFORMANCE_DATA: int
HKEY_CURRENT_CONFIG: int
HKEY_DYN_DATA: int
KEY_WOW64_64KEY: int
KEY_WOW64_32KEY: int

KEY_ALL_ACCESS: int
KEY_WRITE: int
KEY_READ: int
KEY_EXECUTE: int
KEY_QUERY_VALUE: int
KEY_SET_VALUE: int
KEY_CREATE_SUB_KEY: int
KEY_ENUMERATE_SUB_KEYS: int
KEY_NOTIFY: int
KEY_CREATE_LINK: int
REG_BINARY: int
REG_DWORD: int
REG_DWORD_LITTLE_ENDIAN: int
REG_DWORD_BIG_ENDIAN: int
REG_EXPAND_SZ: int
REG_LINK: int
REG_MULTI_SZ: int
REG_NONE: int
REG_RESOURCE_LIST: int
REG_FULL_RESOURCE_DESCRIPTOR: int
REG_RESOURCE_REQUIREMENTS_LIST: int
REG_SZ: int

KEY_WOW64_64KEY: int
KEY_WOW64_32KEY: int
REG_CREATED_NEW_KEY: int # undocumented
REG_LEGAL_CHANGE_FILTER: int # undocumented
REG_LEGAL_OPTION: int # undocumented
REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented
REG_NOTIFY_CHANGE_LAST_SET: int # undocumented
REG_NOTIFY_CHANGE_NAME: int # undocumented
REG_NOTIFY_CHANGE_SECURITY: int # undocumented
REG_NO_LAZY_FLUSH: int # undocumented
REG_OPENED_EXISTING_KEY: int # undocumented
REG_OPTION_BACKUP_RESTORE: int # undocumented
REG_OPTION_CREATE_LINK: int # undocumented
REG_OPTION_NON_VOLATILE: int # undocumented
REG_OPTION_OPEN_LINK: int # undocumented
REG_OPTION_RESERVED: int # undocumented
REG_OPTION_VOLATILE: int # undocumented
REG_REFRESH_HIVE: int # undocumented
REG_WHOLE_HIVE_VOLATILE: int # undocumented

REG_BINARY: int
REG_DWORD: int
REG_DWORD_LITTLE_ENDIAN: int
REG_DWORD_BIG_ENDIAN: int
REG_EXPAND_SZ: int
REG_LINK: int
REG_MULTI_SZ: int
REG_NONE: int
REG_RESOURCE_LIST: int
REG_FULL_RESOURCE_DESCRIPTOR: int
REG_RESOURCE_REQUIREMENTS_LIST: int
REG_SZ: int
error = OSError

REG_CREATED_NEW_KEY: int # undocumented
REG_LEGAL_CHANGE_FILTER: int # undocumented
REG_LEGAL_OPTION: int # undocumented
REG_NOTIFY_CHANGE_ATTRIBUTES: int # undocumented
REG_NOTIFY_CHANGE_LAST_SET: int # undocumented
REG_NOTIFY_CHANGE_NAME: int # undocumented
REG_NOTIFY_CHANGE_SECURITY: int # undocumented
REG_NO_LAZY_FLUSH: int # undocumented
REG_OPENED_EXISTING_KEY: int # undocumented
REG_OPTION_BACKUP_RESTORE: int # undocumented
REG_OPTION_CREATE_LINK: int # undocumented
REG_OPTION_NON_VOLATILE: int # undocumented
REG_OPTION_OPEN_LINK: int # undocumented
REG_OPTION_RESERVED: int # undocumented
REG_OPTION_VOLATILE: int # undocumented
REG_REFRESH_HIVE: int # undocumented
REG_WHOLE_HIVE_VOLATILE: int # undocumented

error = OSError

# Though this class has a __name__ of PyHKEY, it's exposed as HKEYType for some reason
class HKEYType:
def __bool__(self) -> bool: ...
def __int__(self) -> int: ...
def __enter__(self) -> HKEYType: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def Close(self) -> None: ...
def Detach(self) -> int: ...
# Though this class has a __name__ of PyHKEY, it's exposed as HKEYType for some reason
class HKEYType:
def __bool__(self) -> bool: ...
def __int__(self) -> int: ...
def __enter__(self) -> HKEYType: ...
def __exit__(
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> bool | None: ...
def Close(self) -> None: ...
def Detach(self) -> int: ...
3 changes: 1 addition & 2 deletions mypy/typeshed/stdlib/@python2/contextlib.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from types import TracebackType
from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar
from typing_extensions import Protocol
from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Protocol, Type, TypeVar

_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
Expand Down
5 changes: 4 additions & 1 deletion mypy/typeshed/stdlib/@python2/crypt.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
def crypt(word: str, salt: str) -> str: ...
import sys

if sys.platform != "win32":
def crypt(word: str, salt: str) -> str: ...
2 changes: 1 addition & 1 deletion mypy/typeshed/stdlib/@python2/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def create_unicode_buffer(init: _UnionT[int, Text], size: int | None = ...) -> A
if sys.platform == "win32":
def DllCanUnloadNow() -> int: ...
def DllGetClassObject(rclsid: Any, riid: Any, ppv: Any) -> int: ... # TODO not documented
def FormatError(code: int) -> str: ...
def FormatError(code: int = ...) -> str: ...
def GetLastError() -> int: ...

def get_errno() -> int: ...
Expand Down
12 changes: 7 additions & 5 deletions mypy/typeshed/stdlib/@python2/distutils/command/bdist_msi.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from distutils.cmd import Command
import sys

class bdist_msi(Command):
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
if sys.platform == "win32":
from distutils.cmd import Command
class bdist_msi(Command):
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
Loading