Skip to content

Commit aa992b9

Browse files
authored
pywin32: type Get* functions in win32api (#13430)
1 parent 3580566 commit aa992b9

File tree

1 file changed

+93
-46
lines changed

1 file changed

+93
-46
lines changed

stubs/pywin32/win32/win32api.pyi

+93-46
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
from _typeshed import Incomplete, ReadableBuffer
22
from collections.abc import Callable, Iterable
3-
from typing import TypedDict
3+
from typing import Literal, TypedDict, overload, type_check_only
44
from typing_extensions import deprecated
55

66
import _win32typing
77
from win32.lib.pywintypes import TimeType, error as error
88

9+
@type_check_only
910
class _MonitorInfo(TypedDict):
1011
Monitor: tuple[int, int, int, int]
1112
Work: tuple[int, int, int, int]
1213
Flags: int
1314
Device: str
1415

16+
@type_check_only
1517
class _FileVersionInfo(TypedDict):
1618
Signature: int
1719
StrucVersion: int
@@ -26,6 +28,43 @@ class _FileVersionInfo(TypedDict):
2628
FileSubtype: int
2729
FileDate: None | Incomplete
2830

31+
@type_check_only
32+
class _PwrCapabilitiesBatteryScale(TypedDict):
33+
Granularity: int
34+
Capacity: int
35+
36+
@type_check_only
37+
class _PwrCapabilities(TypedDict):
38+
PowerButtonPresent: bool
39+
SleepButtonPresent: bool
40+
LidPresent: bool
41+
SystemS1: bool
42+
SystemS2: bool
43+
SystemS3: bool
44+
SystemS4: bool
45+
SystemS5: bool
46+
HiberFilePresent: bool
47+
FullWake: bool
48+
VideoDimPresent: bool
49+
ApmPresent: bool
50+
UpsPresent: bool
51+
ThermalControl: bool
52+
ProcessorThrottle: bool
53+
ProcessorMinThrottle: int
54+
ProcessorMaxThrottle: int
55+
FastSystemS4: bool
56+
spare2: Incomplete | None
57+
DiskSpinDown: bool
58+
spare3: Incomplete | None
59+
SystemBatteriesPresent: bool
60+
BatteriesAreShortTerm: bool
61+
BatteryScale: tuple[_PwrCapabilitiesBatteryScale, ...]
62+
AcOnLineWake: int
63+
SoftLidWake: int
64+
RtcWake: int
65+
MinDeviceWakeState: int
66+
DefaultLowLatencyWake: int
67+
2968
def AbortSystemShutdown(computerName: str, /) -> None: ...
3069
def InitiateSystemShutdown(computerName: str, message: str, timeOut, bForceClose, bRebootAfterShutdown, /) -> None: ...
3170
def Apply(exceptionHandler, func, args, /): ...
@@ -71,79 +110,87 @@ def FormatMessageW(
71110
) -> str: ...
72111
def FreeLibrary(hModule: int, /) -> None: ...
73112
def GenerateConsoleCtrlEvent(controlEvent: int, processGroupId: int, /) -> None: ...
74-
def GetAsyncKeyState(key, /): ...
113+
def GetAsyncKeyState(key: int, /) -> int: ...
75114
def GetCommandLine() -> str: ...
76115
def GetComputerName() -> str: ...
77-
def GetComputerNameEx(NameType, /) -> str: ...
78-
def GetComputerObjectName(NameFormat, /) -> str: ...
116+
def GetComputerNameEx(NameType: int, /) -> str: ...
117+
def GetComputerObjectName(NameFormat: int, /) -> str: ...
79118
def GetMonitorInfo(hMonitor: int) -> _MonitorInfo: ...
80119
def GetUserName() -> str: ...
81120
def GetUserNameEx(NameFormat: int, /) -> str: ...
82-
def GetCursorPos() -> tuple[Incomplete, Incomplete]: ...
83-
def GetCurrentThread(): ...
84-
def GetCurrentThreadId(): ...
85-
def GetCurrentProcessId(): ...
121+
def GetCursorPos() -> tuple[int, int]: ...
122+
def GetCurrentThread() -> int: ...
123+
def GetCurrentThreadId() -> int: ...
124+
def GetCurrentProcessId() -> int: ...
86125
def GetCurrentProcess() -> int: ...
87126
def GetConsoleTitle() -> str: ...
88-
def GetDateFormat(locale, flags, time: TimeType, _format: str, /) -> str: ...
89-
def GetDiskFreeSpace(rootPath: str, /): ...
90-
def GetDiskFreeSpaceEx(rootPath: str, /) -> tuple[int, int, int]: ...
127+
def GetDateFormat(locale: int, flags: int, time: TimeType | None, _format: str | None = None, /) -> str: ...
128+
def GetDiskFreeSpace(rootPath: str | None = None, /) -> tuple[int, int, int, int]: ...
129+
def GetDiskFreeSpaceEx(rootPath: str | None = None, /) -> tuple[int, int, int]: ...
91130
def GetDllDirectory() -> str: ...
92131
def GetDomainName() -> str: ...
93-
def GetEnvironmentVariable(variable, /): ...
94-
def GetEnvironmentVariableW(Name, /) -> str: ...
95-
def GetFileAttributes(pathName: str, /): ...
132+
def GetEnvironmentVariable(variable: str, /) -> str | None: ...
133+
def GetEnvironmentVariableW(Name: str, /) -> str | None: ...
134+
def GetFileAttributes(pathName: str, /) -> int: ...
96135
def GetFileVersionInfo(Filename: str, SubBlock: str, /) -> _FileVersionInfo: ...
97136
def GetFocus(): ...
98137
def GetFullPathName(fileName: str, /) -> str: ...
99138
def GetHandleInformation(Object: int, /): ...
100-
def GetKeyboardLayout(threadId: int = ..., /): ...
101-
def GetKeyboardLayoutName(): ...
102-
def GetKeyboardState() -> str: ...
103-
def GetKeyState(key, /): ...
104-
def GetLastError(): ...
105-
def GetLastInputInfo(): ...
106-
def GetLocalTime(): ...
139+
def GetKeyboardLayout(threadId: int = ..., /) -> int: ...
140+
def GetKeyboardLayoutName() -> str: ...
141+
def GetKeyboardState() -> bytes: ...
142+
def GetKeyState(key: int, /) -> int: ...
143+
def GetLastError() -> int: ...
144+
def GetLastInputInfo() -> int: ...
145+
def GetLocalTime() -> tuple[int, int, int, int, int, int, int, int]: ...
107146
def GetLongPathName(fileName: str, /) -> str: ...
108147
def GetLongPathNameW(fileName: str, /) -> str: ...
109-
def GetLogicalDrives(): ...
148+
def GetLogicalDrives() -> int: ...
110149
def GetLogicalDriveStrings() -> str: ...
111-
def GetModuleFileName(hModule: int, /) -> str: ...
112-
def GetModuleFileNameW(hModule: int, /) -> str: ...
113-
def GetModuleHandle(fileName: str | None = ..., /) -> int: ...
114-
def GetPwrCapabilities(): ...
150+
def GetModuleFileName(hModule: int | None, /) -> str: ...
151+
def GetModuleFileNameW(hModule: int | None, /) -> str: ...
152+
def GetModuleHandle(fileName: str | None = None, /) -> int: ...
153+
def GetPwrCapabilities() -> _PwrCapabilities: ...
115154
@deprecated("This function is obsolete, applications should use the registry instead.")
116-
def GetProfileSection(section: str, iniName: str | None = ..., /): ...
155+
def GetProfileSection(section: str, iniName: str | None = ..., /) -> list[Incomplete]: ...
117156
def GetProcAddress(hModule: int, functionName: _win32typing.PyResourceId, /): ...
118157
@deprecated("This function is obsolete, applications should use the registry instead.")
119158
def GetProfileVal(section: str, entry: str, defValue: str, iniName: str | None = ..., /) -> str: ...
120159
def GetShortPathName(path: str, /) -> str: ...
121-
def GetStdHandle(handle: int, /) -> _win32typing.PyHANDLE: ...
160+
def GetStdHandle(handle: int, /) -> int: ...
122161
def GetSysColor(index: int, /) -> int: ...
123-
def GetSystemDefaultLangID(): ...
124-
def GetSystemDefaultLCID(): ...
162+
def GetSystemDefaultLangID() -> int: ...
163+
def GetSystemDefaultLCID() -> int: ...
125164
def GetSystemDirectory() -> str: ...
126-
def GetSystemFileCacheSize(): ...
127-
def SetSystemFileCacheSize(MinimumFileCacheSize, MaximumFileCacheSize, Flags=...) -> None: ...
128-
def GetSystemInfo(): ...
129-
def GetNativeSystemInfo(): ...
165+
def GetSystemFileCacheSize() -> tuple[int, int, int]: ...
166+
def SetSystemFileCacheSize(MinimumFileCacheSize: int, MaximumFileCacheSize: int, Flags: int = ...) -> None: ...
167+
def GetSystemInfo() -> tuple[int, int, int, int, int, int, int, int, tuple[int, int]]: ...
168+
def GetNativeSystemInfo() -> tuple[int, int, int, int, int, int, int, int, tuple[int, int]]: ...
130169
def GetSystemMetrics(index: int, /) -> int: ...
131170
def GetSystemPowerStatus() -> dict[str, int]: ...
132-
def GetSystemTime(): ...
133-
def GetTempFileName(path: str, prefix: str, nUnique, /): ...
171+
def GetSystemTime() -> tuple[int, int, int, int, int, int, int, int]: ...
172+
def GetTempFileName(path: str, prefix: str, nUnique: int = ..., /) -> tuple[str, int]: ...
134173
def GetTempPath() -> str: ...
135-
def GetThreadLocale(): ...
174+
def GetThreadLocale() -> int: ...
136175
def GetTickCount() -> int: ...
137-
def GetTimeFormat(locale, flags, time: TimeType, _format: str, /) -> str: ...
138-
def GetTimeZoneInformation(times_as_tuples: bool = ..., /): ...
139-
def GetVersion(): ...
140-
def GetVersionEx(_format: int = ..., /): ...
141-
def GetVolumeInformation(path: str, /): ...
176+
def GetTimeFormat(locale: int, flags: int, time: TimeType | None, _format: str, /) -> str: ...
177+
@overload
178+
def GetTimeZoneInformation(
179+
times_as_tuples: Literal[True] = True, /
180+
) -> tuple[
181+
int,
182+
tuple[int, str, tuple[int, int, int, int, int, int, int, int], int, str, tuple[int, int, int, int, int, int, int, int], int],
183+
]: ...
184+
@overload
185+
def GetTimeZoneInformation(times_as_tuples: Literal[False], /): ...
186+
def GetVersion() -> int: ...
187+
def GetVersionEx(_format: int = ..., /) -> tuple[int, int, int, int, str]: ...
188+
def GetVolumeInformation(path: str, /) -> tuple[str, int, int, int, str]: ...
142189
def GetWindowsDirectory() -> str: ...
143190
def GetWindowLong(hwnd: int | None, offset: int, /) -> int: ...
144-
def GetUserDefaultLangID(): ...
145-
def GetUserDefaultLCID(): ...
146-
def GlobalMemoryStatus(): ...
191+
def GetUserDefaultLangID() -> int: ...
192+
def GetUserDefaultLCID() -> int: ...
193+
def GlobalMemoryStatus() -> dict[str, int]: ...
147194
def GlobalMemoryStatusEx() -> dict[str, int]: ...
148195
def keybd_event(bVk, bScan, dwFlags: int = ..., dwExtraInfo: int = ..., /) -> None: ...
149196
def mouse_event(dx, dy, dwData, dwFlags: int = ..., dwExtraInfo=..., /) -> None: ...
@@ -268,7 +315,7 @@ def MAKELANGID(PrimaryLanguage, SubLanguage, /): ...
268315
def MAKEWORD(low, high, /): ...
269316
def MAKELONG(low, high, /): ...
270317
def CommandLineToArgv(*args): ... # incomplete
271-
def GetKeyboardLayoutList(*args): ... # incomplete
318+
def GetKeyboardLayoutList() -> tuple[int, int]: ...
272319
def MapVirtualKey(*args): ... # incomplete
273320
def MessageBoxEx(*args): ... # incomplete
274321
def OpenThread(*args): ... # incomplete

0 commit comments

Comments
 (0)