Skip to content

Commit 4cf9d47

Browse files
author
typeshedbot
committed
Sync Windows docstrings
1 parent 244d63e commit 4cf9d47

File tree

33 files changed

+1265
-146
lines changed

33 files changed

+1265
-146
lines changed

crates/ty_vendored/vendor/typeshed/stdlib/_ctypes.pyi

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,42 @@ if sys.platform == "win32":
3131
_COMError_Details: TypeAlias = tuple[str | None, str | None, str | None, int | None, int | None]
3232

3333
class COMError(Exception):
34+
"""Raised when a COM method call failed.
35+
"""
3436
hresult: int
3537
text: str | None
3638
details: _COMError_Details
3739

3840
def __init__(self, hresult: int, text: str | None, details: _COMError_Details) -> None: ...
3941

40-
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int: ...
42+
def CopyComPointer(src: _PointerLike, dst: _PointerLike | _CArgObject) -> int:
43+
"""CopyComPointer(src, dst) -> HRESULT value
44+
"""
4145

4246
FUNCFLAG_HRESULT: Final = 0x2
4347
FUNCFLAG_STDCALL: Final = 0x0
4448

45-
def FormatError(code: int = ...) -> str: ...
49+
def FormatError(code: int = ...) -> str:
50+
"""FormatError([integer]) -> string
51+
52+
Convert a win32 error code into a string. If the error code is not
53+
given, the return value of a call to GetLastError() is used.
54+
"""
4655
def get_last_error() -> int: ...
4756
def set_last_error(value: int) -> int: ...
48-
def LoadLibrary(name: str, load_flags: int = 0, /) -> int: ...
49-
def FreeLibrary(handle: int, /) -> None: ...
57+
def LoadLibrary(name: str, load_flags: int = 0, /) -> int:
58+
"""LoadLibrary(name, load_flags) -> handle
59+
60+
Load an executable (usually a DLL), and return a handle to it.
61+
The handle may be used to locate exported functions in this
62+
module. load_flags are as defined for LoadLibraryEx in the
63+
Windows API.
64+
"""
65+
def FreeLibrary(handle: int, /) -> None:
66+
"""FreeLibrary(handle) -> void
67+
68+
Free the handle of an executable previously loaded by LoadLibrary.
69+
"""
5070

5171
else:
5272
def dlclose(handle: int, /) -> None:

crates/ty_vendored/vendor/typeshed/stdlib/_msi.pyi

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Documentation
2+
"""
13
import sys
24
from typing import Final, type_check_only
35

@@ -51,10 +53,32 @@ if sys.platform == "win32":
5153
__new__: None # type: ignore[assignment]
5254
__init__: None # type: ignore[assignment]
5355

54-
def UuidCreate() -> str: ...
55-
def FCICreate(cabname: str, files: list[str], /) -> None: ...
56-
def OpenDatabase(path: str, persist: int, /) -> _Database: ...
57-
def CreateRecord(count: int, /) -> _Record: ...
56+
def UuidCreate() -> str:
57+
"""Return the string representation of a new unique identifier.
58+
"""
59+
def FCICreate(cabname: str, files: list[str], /) -> None:
60+
"""Create a new CAB file.
61+
62+
cabname
63+
the name of the CAB file
64+
files
65+
a list of tuples, each containing the name of the file on disk,
66+
and the name of the file inside the CAB file
67+
"""
68+
def OpenDatabase(path: str, persist: int, /) -> _Database:
69+
"""Return a new database object.
70+
71+
path
72+
the file name of the MSI file
73+
persist
74+
the persistence mode
75+
"""
76+
def CreateRecord(count: int, /) -> _Record:
77+
"""Return a new record object.
78+
79+
count
80+
the number of fields of the record
81+
"""
5882

5983
MSICOLINFO_NAMES: Final[int]
6084
MSICOLINFO_TYPES: Final[int]

crates/ty_vendored/vendor/typeshed/stdlib/_socket.pyi

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,14 @@ operations. A timeout of None indicates that timeouts on socket
880880
operations are disabled.
881881
"""
882882
if sys.platform == "win32":
883-
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool, /) -> None: ...
883+
def ioctl(self, control: int, option: int | tuple[int, int, int] | bool, /) -> None:
884+
"""ioctl(cmd, option) -> long
885+
886+
Control the socket with WSAIoctl syscall. Currently supported 'cmd' values are
887+
SIO_RCVALL: 'option' must be one of the socket.RCVALL_* constants.
888+
SIO_KEEPALIVE_VALS: 'option' is a tuple of (onoff, timeout, interval).
889+
SIO_LOOPBACK_FAST_PATH: 'option' is a boolean value, and is disabled by default
890+
"""
884891

885892
def listen(self, backlog: int = ..., /) -> None:
886893
"""listen([backlog])
@@ -1070,7 +1077,14 @@ None, optlen.
10701077
@overload
10711078
def setsockopt(self, level: int, optname: int, value: None, optlen: int, /) -> None: ...
10721079
if sys.platform == "win32":
1073-
def share(self, process_id: int, /) -> bytes: ...
1080+
def share(self, process_id: int, /) -> bytes:
1081+
"""share(process_id) -> bytes
1082+
1083+
Share the socket with another process. The target process id
1084+
must be provided and the resulting bytes object passed to the target
1085+
process. There the shared socket can be instantiated by calling
1086+
socket.fromshare().
1087+
"""
10741088

10751089
def shutdown(self, how: int, /) -> None:
10761090
"""shutdown(flag)

crates/ty_vendored/vendor/typeshed/stdlib/_ssl.pyi

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,23 @@ The values are 'cert_file_env', 'cert_file', 'cert_dir_env', 'cert_dir'.
8686

8787
if sys.platform == "win32":
8888
_EnumRetType: TypeAlias = list[tuple[bytes, str, set[str] | bool]]
89-
def enum_certificates(store_name: str) -> _EnumRetType: ...
90-
def enum_crls(store_name: str) -> _EnumRetType: ...
89+
def enum_certificates(store_name: str) -> _EnumRetType:
90+
"""Retrieve certificates from Windows' cert store.
91+
92+
store_name may be one of 'CA', 'ROOT' or 'MY'. The system may provide
93+
more cert storages, too. The function returns a list of (bytes,
94+
encoding_type, trust) tuples. The encoding_type flag can be interpreted
95+
with X509_ASN_ENCODING or PKCS_7_ASN_ENCODING. The trust setting is either
96+
a set of OIDs or the boolean True.
97+
"""
98+
def enum_crls(store_name: str) -> _EnumRetType:
99+
"""Retrieve CRLs from Windows' cert store.
100+
101+
store_name may be one of 'CA', 'ROOT' or 'MY'. The system may provide
102+
more cert storages, too. The function returns a list of (bytes,
103+
encoding_type) tuples. The encoding_type flag can be interpreted with
104+
X509_ASN_ENCODING or PKCS_7_ASN_ENCODING.
105+
"""
91106

92107
def txt2obj(txt: str, name: bool = False) -> tuple[int, str, str, str]:
93108
"""Lookup NID, short name, long name and OID of an ASN1_OBJECT.

crates/ty_vendored/vendor/typeshed/stdlib/_winapi.pyi

Lines changed: 114 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ if sys.platform == "win32":
175175
if sys.version_info >= (3, 14):
176176
COPY_FILE_DIRECTORY: Final = 0x00000080
177177

178-
def CloseHandle(handle: int, /) -> None: ...
178+
def CloseHandle(handle: int, /) -> None:
179+
"""Close handle.
180+
"""
179181
@overload
180182
def ConnectNamedPipe(handle: int, overlapped: Literal[True]) -> Overlapped: ...
181183
@overload
@@ -204,7 +206,14 @@ if sys.platform == "win32":
204206
security_attributes: int,
205207
/,
206208
) -> int: ...
207-
def CreatePipe(pipe_attrs: Any, size: int, /) -> tuple[int, int]: ...
209+
def CreatePipe(pipe_attrs: Any, size: int, /) -> tuple[int, int]:
210+
"""Create an anonymous pipe.
211+
212+
pipe_attrs
213+
Ignored internally, can be None.
214+
215+
Returns a 2-tuple of handles, to the read and write ends of the pipe.
216+
"""
208217
def CreateProcess(
209218
application_name: str | None,
210219
command_line: str | None,
@@ -216,7 +225,19 @@ if sys.platform == "win32":
216225
current_directory: str | None,
217226
startup_info: Any,
218227
/,
219-
) -> tuple[int, int, int, int]: ...
228+
) -> tuple[int, int, int, int]:
229+
"""Create a new process and its primary thread.
230+
231+
command_line
232+
Can be str or None
233+
proc_attrs
234+
Ignored internally, can be None.
235+
thread_attrs
236+
Ignored internally, can be None.
237+
238+
The return value is a tuple of the process handle, thread handle,
239+
process ID, and thread ID.
240+
"""
220241
def DuplicateHandle(
221242
source_process_handle: int,
222243
source_handle: int,
@@ -225,16 +246,46 @@ if sys.platform == "win32":
225246
inherit_handle: bool,
226247
options: int = 0,
227248
/,
228-
) -> int: ...
249+
) -> int:
250+
"""Return a duplicate handle object.
251+
252+
The duplicate handle refers to the same object as the original
253+
handle. Therefore, any changes to the object are reflected
254+
through both handles.
255+
"""
229256
def ExitProcess(ExitCode: int, /) -> NoReturn: ...
230-
def GetACP() -> int: ...
257+
def GetACP() -> int:
258+
"""Get the current Windows ANSI code page identifier.
259+
"""
231260
def GetFileType(handle: int) -> int: ...
232-
def GetCurrentProcess() -> int: ...
233-
def GetExitCodeProcess(process: int, /) -> int: ...
261+
def GetCurrentProcess() -> int:
262+
"""Return a handle object for the current process.
263+
"""
264+
def GetExitCodeProcess(process: int, /) -> int:
265+
"""Return the termination status of the specified process.
266+
"""
234267
def GetLastError() -> int: ...
235-
def GetModuleFileName(module_handle: int, /) -> str: ...
236-
def GetStdHandle(std_handle: int, /) -> int: ...
237-
def GetVersion() -> int: ...
268+
def GetModuleFileName(module_handle: int, /) -> str:
269+
"""Return the fully-qualified path for the file that contains module.
270+
271+
The module must have been loaded by the current process.
272+
273+
The module parameter should be a handle to the loaded module
274+
whose path is being requested. If this parameter is 0,
275+
GetModuleFileName retrieves the path of the executable file
276+
of the current process.
277+
"""
278+
def GetStdHandle(std_handle: int, /) -> int:
279+
"""Return a handle to the specified standard device.
280+
281+
std_handle
282+
One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.
283+
284+
The integer associated with the handle object is returned.
285+
"""
286+
def GetVersion() -> int:
287+
"""Return the version number of the current operating system.
288+
"""
238289
def OpenProcess(desired_access: int, inherit_handle: bool, process_id: int, /) -> int: ...
239290
def PeekNamedPipe(handle: int, size: int = 0, /) -> tuple[int, int] | tuple[bytes, int, int]: ...
240291
if sys.version_info >= (3, 10):
@@ -250,9 +301,17 @@ if sys.platform == "win32":
250301
def SetNamedPipeHandleState(
251302
named_pipe: int, mode: int | None, max_collection_count: int | None, collect_data_timeout: int | None, /
252303
) -> None: ...
253-
def TerminateProcess(handle: int, exit_code: int, /) -> None: ...
304+
def TerminateProcess(handle: int, exit_code: int, /) -> None:
305+
"""Terminate the specified process and all of its threads.
306+
"""
254307
def WaitForMultipleObjects(handle_seq: Sequence[int], wait_flag: bool, milliseconds: int = 0xFFFFFFFF, /) -> int: ...
255-
def WaitForSingleObject(handle: int, milliseconds: int, /) -> int: ...
308+
def WaitForSingleObject(handle: int, milliseconds: int, /) -> int:
309+
"""Wait for a single object.
310+
311+
Wait until the specified object is in the signaled state or
312+
the time-out interval elapses. The timeout value is specified
313+
in milliseconds.
314+
"""
256315
def WaitNamedPipe(name: str, timeout: int, /) -> None: ...
257316
@overload
258317
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: Literal[True]) -> tuple[Overlapped, int]: ...
@@ -262,6 +321,8 @@ if sys.platform == "win32":
262321
def WriteFile(handle: int, buffer: ReadableBuffer, overlapped: int | bool) -> tuple[Any, int]: ...
263322
@final
264323
class Overlapped:
324+
"""OVERLAPPED structure wrapper
325+
"""
265326
event: int
266327
def GetOverlappedResult(self, wait: bool, /) -> tuple[int, int]: ...
267328
def cancel(self) -> None: ...
@@ -270,17 +331,54 @@ if sys.platform == "win32":
270331
if sys.version_info >= (3, 13):
271332
def BatchedWaitForMultipleObjects(
272333
handle_seq: Sequence[int], wait_all: bool, milliseconds: int = 0xFFFFFFFF
273-
) -> list[int]: ...
334+
) -> list[int]:
335+
"""Supports a larger number of handles than WaitForMultipleObjects
336+
337+
Note that the handles may be waited on other threads, which could cause
338+
issues for objects like mutexes that become associated with the thread
339+
that was waiting for them. Objects may also be left signalled, even if
340+
the wait fails.
341+
342+
It is recommended to use WaitForMultipleObjects whenever possible, and
343+
only switch to BatchedWaitForMultipleObjects for scenarios where you
344+
control all the handles involved, such as your own thread pool or
345+
files, and all wait objects are left unmodified by a wait (for example,
346+
manual reset events, threads, and files/pipes).
347+
348+
Overlapped handles returned from this module use manual reset events.
349+
"""
274350
def CreateEventW(security_attributes: int, manual_reset: bool, initial_state: bool, name: str | None) -> int: ...
275351
def CreateMutexW(security_attributes: int, initial_owner: bool, name: str) -> int: ...
276-
def GetLongPathName(path: str) -> str: ...
277-
def GetShortPathName(path: str) -> str: ...
352+
def GetLongPathName(path: str) -> str:
353+
"""Return the long version of the provided path.
354+
355+
If the path is already in its long form, returns the same value.
356+
357+
The path must already be a 'str'. If the type is not known, use
358+
os.fsdecode before calling this function.
359+
"""
360+
def GetShortPathName(path: str) -> str:
361+
"""Return the short version of the provided path.
362+
363+
If the path is already in its short form, returns the same value.
364+
365+
The path must already be a 'str'. If the type is not known, use
366+
os.fsdecode before calling this function.
367+
"""
278368
def OpenEventW(desired_access: int, inherit_handle: bool, name: str) -> int: ...
279369
def OpenMutexW(desired_access: int, inherit_handle: bool, name: str) -> int: ...
280370
def ReleaseMutex(mutex: int) -> None: ...
281371
def ResetEvent(event: int) -> None: ...
282372
def SetEvent(event: int) -> None: ...
283373

284374
if sys.version_info >= (3, 12):
285-
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int: ...
375+
def CopyFile2(existing_file_name: str, new_file_name: str, flags: int, progress_routine: int | None = None) -> int:
376+
"""Copies a file from one name to a new name.
377+
378+
This is implemented using the CopyFile2 API, which preserves all stat
379+
and metadata information apart from security attributes.
380+
381+
progress_routine is reserved for future use, but is currently not
382+
implemented. Its value is ignored.
383+
"""
286384
def NeedCurrentDirectoryForExePath(exe_name: str, /) -> bool: ...

0 commit comments

Comments
 (0)