pywin32: Improve some types (#9089)

This commit is contained in:
Samuel T
2022-11-04 17:48:53 -07:00
committed by GitHub
parent 4329404b1c
commit 98dac4c926
9 changed files with 276 additions and 239 deletions
+129 -123
View File
@@ -1,10 +1,30 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, ReadableBuffer
from array import array
from typing import NamedTuple
is64bit: bool
def UnpackWMNOTIFY(lparam) -> tuple[Incomplete, ...]: ...
def UnpackNMITEMACTIVATE(lparam) -> tuple[Incomplete, ...]: ...
class _WMNOTIFY(NamedTuple):
hwndFrom: Incomplete
idFrom: Incomplete
code: Incomplete
def UnpackWMNOTIFY(lparam: int) -> _WMNOTIFY: ...
class _NMITEMACTIVATE(NamedTuple):
hwndFrom: Incomplete
idFrom: Incomplete
code: Incomplete
iItem: Incomplete
iSubItem: Incomplete
uNewState: Incomplete
uOldState: Incomplete
uChanged: Incomplete
actionx: Incomplete
actiony: Incomplete
lParam: Incomplete
def UnpackNMITEMACTIVATE(lparam) -> _NMITEMACTIVATE: ...
def PackMENUITEMINFO(
fType: Incomplete | None = ...,
fState: Incomplete | None = ...,
@@ -17,20 +37,20 @@ def PackMENUITEMINFO(
hbmpItem: Incomplete | None = ...,
dwTypeData: Incomplete | None = ...,
) -> tuple[array[int], list[Incomplete]]: ...
def UnpackMENUITEMINFO(
s,
) -> tuple[
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
str | None,
Incomplete | None,
]: ...
def EmptyMENUITEMINFO(mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[Incomplete]]: ...
class _MENUITEMINFO(NamedTuple):
fType: int | None
fState: int | None
wID: int | None
hSubMenu: int | None
hbmpChecked: int | None
hbmpUnchecked: int | None
dwItemData: int | None
text: str | None
hbmpItem: int | None
def UnpackMENUITEMINFO(s: ReadableBuffer) -> _MENUITEMINFO: ...
def EmptyMENUITEMINFO(mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[array[int]]]: ...
def PackMENUINFO(
dwStyle: Incomplete | None = ...,
cyMax: Incomplete | None = ...,
@@ -39,68 +59,49 @@ def PackMENUINFO(
dwMenuData: Incomplete | None = ...,
fMask: int = ...,
) -> array[int]: ...
def UnpackMENUINFO(s) -> tuple[Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None]: ...
class _MENUINFO(NamedTuple):
dwStyle: Incomplete | None
cyMax: Incomplete | None
hbrBack: Incomplete | None
dwContextHelpID: Incomplete | None
dwMenuData: Incomplete | None
def UnpackMENUINFO(s: ReadableBuffer) -> _MENUINFO: ...
def EmptyMENUINFO(mask: Incomplete | None = ...) -> array[int]: ...
def PackTVINSERTSTRUCT(parent, insertAfter, tvitem) -> tuple[bytes, list[Incomplete]]: ...
def PackTVITEM(hitem, state, stateMask, text, image, selimage, citems, param) -> tuple[array[int], list[Incomplete]]: ...
def EmptyTVITEM(hitem, mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[Incomplete]]: ...
def UnpackTVITEM(
buffer,
) -> tuple[
Incomplete,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
]: ...
def UnpackTVNOTIFY(
lparam,
) -> tuple[
Incomplete,
Incomplete,
Incomplete,
Incomplete,
tuple[
Incomplete,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
],
tuple[
Incomplete,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
],
]: ...
def UnpackTVDISPINFO(
lparam,
) -> tuple[
Incomplete,
Incomplete,
Incomplete,
tuple[
Incomplete,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
],
]: ...
class _TVITEM(NamedTuple):
item_hItem: Incomplete
item_state: Incomplete | None
item_stateMask: Incomplete | None
text: Incomplete | None
item_image: Incomplete | None
item_selimage: Incomplete | None
item_cChildren: Incomplete | None
item_param: Incomplete | None
def UnpackTVITEM(buffer: ReadableBuffer) -> _TVITEM: ...
class _TVNOTIFY(NamedTuple):
hwndFrom: Incomplete
id: Incomplete
code: Incomplete
action: Incomplete
item_old: _TVITEM
item_new: _TVITEM
def UnpackTVNOTIFY(lparam: int) -> _TVNOTIFY: ...
class _TVDISPINFO(NamedTuple):
hwndFrom: Incomplete
id: Incomplete
code: Incomplete
item: _TVITEM
def UnpackTVDISPINFO(lparam: int) -> _TVDISPINFO: ...
def PackLVITEM(
item: Incomplete | None = ...,
subItem: Incomplete | None = ...,
@@ -111,49 +112,40 @@ def PackLVITEM(
param: Incomplete | None = ...,
indent: Incomplete | None = ...,
) -> tuple[array[int], list[Incomplete]]: ...
def UnpackLVITEM(
buffer,
) -> tuple[
Incomplete,
Incomplete,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
]: ...
def UnpackLVDISPINFO(
lparam,
) -> tuple[
Incomplete,
Incomplete,
Incomplete,
tuple[
Incomplete,
Incomplete,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
Incomplete | None,
],
]: ...
def UnpackLVNOTIFY(
lparam,
) -> tuple[
Incomplete,
Incomplete,
Incomplete,
Incomplete,
Incomplete,
Incomplete,
Incomplete,
Incomplete,
tuple[Incomplete, Incomplete],
Incomplete,
]: ...
class _LVITEM(NamedTuple):
item_item: Incomplete
item_subItem: Incomplete
item_state: Incomplete | None
item_stateMask: Incomplete | None
text: Incomplete | None
item_image: Incomplete | None
item_param: Incomplete | None
item_indent: Incomplete | None
def UnpackLVITEM(buffer: ReadableBuffer) -> _LVITEM: ...
class _LVDISPINFO(NamedTuple):
hwndFrom: Incomplete
id: Incomplete
code: Incomplete
item: _LVITEM
def UnpackLVDISPINFO(lparam: int) -> _LVDISPINFO: ...
class _UnpackLVNOTIFY(NamedTuple):
hwndFrom: Incomplete
id: Incomplete
code: Incomplete
item: Incomplete
subitem: Incomplete
newstate: Incomplete
oldstate: Incomplete
changed: Incomplete
pt: tuple[Incomplete, Incomplete]
lparam: Incomplete
def UnpackLVNOTIFY(lparam: int) -> _UnpackLVNOTIFY: ...
def EmptyLVITEM(
item, subitem, mask: Incomplete | None = ..., text_buf_size: int = ...
) -> tuple[array[int], list[Incomplete]]: ...
@@ -165,12 +157,26 @@ def PackLVCOLUMN(
image: Incomplete | None = ...,
order: Incomplete | None = ...,
) -> tuple[array[int], list[Incomplete]]: ...
def UnpackLVCOLUMN(
lparam,
) -> tuple[Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None, Incomplete | None]: ...
class _LVCOLUMN(NamedTuple):
fmt: Incomplete | None
cx: Incomplete | None
text: Incomplete | None
subItem: Incomplete | None
image: Incomplete | None
order: Incomplete | None
def UnpackLVCOLUMN(lparam: ReadableBuffer) -> _LVCOLUMN: ...
def EmptyLVCOLUMN(mask: Incomplete | None = ..., text_buf_size: int = ...) -> tuple[array[int], list[Incomplete]]: ...
def PackLVHITTEST(pt) -> tuple[array[int], None]: ...
def UnpackLVHITTEST(buf) -> tuple[tuple[Incomplete, Incomplete], Incomplete, Incomplete, Incomplete]: ...
class _LVHITTEST(NamedTuple):
pt: tuple[Incomplete, Incomplete]
flags: Incomplete
item: Incomplete
subitem: Incomplete
def UnpackLVHITTEST(buf: ReadableBuffer) -> tuple[tuple[Incomplete, Incomplete], Incomplete, Incomplete, Incomplete]: ...
def PackHDITEM(
cxy: Incomplete | None = ...,
text: Incomplete | None = ...,
@@ -189,4 +195,4 @@ class DEV_BROADCAST_INFO:
devicetype: Incomplete
def __init__(self, devicetype, **kw) -> None: ...
def UnpackDEV_BROADCAST(lparam) -> DEV_BROADCAST_INFO | None: ...
def UnpackDEV_BROADCAST(lparam: int) -> DEV_BROADCAST_INFO | None: ...
+12 -3
View File
@@ -1,8 +1,15 @@
from _typeshed import Incomplete
from typing_extensions import TypedDict
import _win32typing
from win32.lib.pywintypes import error as error
class _MonitorInfo(TypedDict):
Monitor: tuple[int, int, int, int]
Work: tuple[int, int, int, int]
Flags: int
Device: str
def AbortSystemShutdown(computerName: str) -> None: ...
def InitiateSystemShutdown(computerName: str, message: str, timeOut, bForceClose, bRebootAfterShutdown) -> None: ...
def Apply(exceptionHandler, func, args): ...
@@ -21,8 +28,10 @@ def DuplicateHandle(
hSourceProcess: int, hSource: int, hTargetProcessHandle: int, desiredAccess, bInheritHandle, options
) -> int: ...
def EndUpdateResource(handle: int, discard) -> None: ...
def EnumDisplayDevices(Device: str | None = ..., DevNum: int = ..., Flags=...) -> _win32typing.PyDISPLAY_DEVICE: ...
def EnumDisplayMonitors(hdc: int | None = ..., rcClip: _win32typing.PyRECT | None = ...): ...
def EnumDisplayDevices(Device: str | None = ..., DevNum: int = ..., Flags: int = ...) -> _win32typing.PyDISPLAY_DEVICE: ...
def EnumDisplayMonitors(
hdc: int | None = ..., rcClip: _win32typing.PyRECT | None = ...
) -> list[tuple[_win32typing.PyHANDLE, _win32typing.PyHANDLE, tuple[int, int, int, int]]]: ...
def EnumDisplaySettings(DeviceName: str | None = ..., ModeNum: int = ...) -> _win32typing.PyDEVMODE: ...
def EnumDisplaySettingsEx(ModeNum, DeviceName: str | None = ..., Flags=...) -> _win32typing.PyDEVMODE: ...
def EnumResourceLanguages(
@@ -47,7 +56,7 @@ def GetCommandLine() -> str: ...
def GetComputerName() -> str: ...
def GetComputerNameEx(NameType) -> str: ...
def GetComputerObjectName(NameFormat) -> str: ...
def GetMonitorInfo(hMonitor: int): ...
def GetMonitorInfo(hMonitor: int) -> _MonitorInfo: ...
def GetUserName() -> str: ...
def GetUserNameEx(NameFormat) -> str: ...
def GetCursorPos() -> tuple[Incomplete, Incomplete]: ...
+37 -20
View File
@@ -1,15 +1,19 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, ReadableBuffer, WriteableBuffer
from collections.abc import Callable
from typing import TypeVar
import _win32typing
from win32.lib.pywintypes import error as error
_T = TypeVar("_T")
def EnumFontFamilies(hdc: int, Family: str, EnumFontFamProc, Param): ...
def set_logger(logger) -> None: ...
def LOGFONT() -> _win32typing.PyLOGFONT: ...
def CreateFontIndirect(lplf: _win32typing.PyLOGFONT): ...
def GetObject(handle: int): ...
def GetObjectType(h: int): ...
def PyGetMemory(addr, _len): ...
def PyGetMemory(__addr: int, __len: int): ...
def PyGetString(addr, _len) -> str: ...
def PySetString(addr, String, maxLen): ...
def PySetMemory(addr, String): ...
@@ -21,16 +25,29 @@ def GetWindowLong(hwnd: int, index): ...
def GetClassLong(hwnd: int, index): ...
def SetWindowLong(hwnd: int, index, value): ...
def CallWindowProc(wndproc, hwnd: int, msg, wparam, lparam): ...
def SendMessage(hwnd: int, message, wparam: Incomplete | None = ..., lparam: Incomplete | None = ...): ...
def SendMessageTimeout(hwnd: int, message, wparam, lparam, flags, timeout) -> tuple[Incomplete, Incomplete]: ...
def PostMessage(hwnd: int, message, wparam: int = ..., lparam: int = ...) -> None: ...
def SendMessage(
__hwnd: int | None, __message: int, __wparam: int | None = ..., __lparam: ReadableBuffer | float | None = ...
) -> int: ...
def SendMessageTimeout(
__hwnd: int,
__message: int,
__wparam: ReadableBuffer | float | None,
__lparam: ReadableBuffer | float | None,
__flags: int,
__timeout: int,
) -> tuple[int, int]: ...
def PostMessage(
__hwnd: int | None, __message: int, __wparam: int | None = ..., __lparam: ReadableBuffer | float | None = ...
) -> None: ...
def PostThreadMessage(threadId, message, wparam, lparam) -> None: ...
def ReplyMessage(result): ...
def RegisterWindowMessage(name: str): ...
def DefWindowProc(hwnd: int, message, wparam, lparam): ...
def EnumWindows(callback, extra) -> None: ...
def EnumThreadWindows(dwThreadId, callback, extra) -> None: ...
def EnumChildWindows(hwnd: int, callback, extra) -> None: ...
def DefWindowProc(
hwnd: int | None, message: int, wparam: ReadableBuffer | float | None, lparam: ReadableBuffer | float | None
) -> int: ...
def EnumWindows(__callback: Callable[[int, _T], object], __extra: _T) -> None: ...
def EnumThreadWindows(dwThreadId, __callback: Callable[[int, _T], object], __extra: _T) -> None: ...
def EnumChildWindows(__hwnd: int | None, __callback: Callable[[int, _T], object], __extra: _T) -> None: ...
def DialogBox(hInstance: int, TemplateName: _win32typing.PyResourceId, hWndParent: int, DialogFunc, InitParam: int = ...): ...
def DialogBoxParam(): ...
def DialogBoxIndirect(
@@ -113,7 +130,7 @@ def HideCaret(hWnd: int) -> None: ...
def SetCaretPos(x, y) -> None: ...
def GetCaretPos() -> tuple[Incomplete, Incomplete]: ...
def ShowCaret(hWnd: int) -> None: ...
def ShowWindow(hWnd: int, cmdShow): ...
def ShowWindow(__hWnd: int | None, __cmdShow: int) -> int: ...
def IsWindowVisible(__hwnd: int | None) -> int: ...
def IsWindowEnabled(__hwnd: int | None) -> int: ...
def SetFocus(hwnd: int) -> None: ...
@@ -122,8 +139,8 @@ def UpdateWindow(hwnd: int) -> None: ...
def BringWindowToTop(hwnd: int) -> None: ...
def SetActiveWindow(hwnd: int): ...
def GetActiveWindow(): ...
def SetForegroundWindow(hwnd: int): ...
def GetForegroundWindow(): ...
def SetForegroundWindow(__hwnd: int) -> None: ...
def GetForegroundWindow() -> int: ...
def GetClientRect(hwnd: int) -> tuple[int, int, int, int]: ...
def GetDC(hwnd: int): ...
def SaveDC(hdc: int): ...
@@ -138,7 +155,7 @@ def GetWindowRect(hwnd: int) -> tuple[int, int, int, int]: ...
def GetStockObject(Object) -> int: ...
def PostQuitMessage(rc) -> None: ...
def WaitMessage() -> None: ...
def SetWindowPos(hWnd: int, InsertAfter: int, X, Y, cx, cy, Flags) -> None: ...
def SetWindowPos(__hWnd: int, __InsertAfter: int | None, __X: int, __Y: int, __cx: int, __cy: int, __Flags: int) -> None: ...
def GetWindowPlacement(__hwnd: int) -> tuple[int, int, tuple[int, int], tuple[int, int], tuple[int, int, int, int]]: ...
def SetWindowPlacement(hWnd: int, placement) -> None: ...
def RegisterClass(wndClass: _win32typing.PyWNDCLASS): ...
@@ -153,7 +170,7 @@ def PeekMessage(hwnd: int, filterMin, filterMax, removalOptions): ...
def Shell_NotifyIcon(Message, nid: _win32typing.PyNOTIFYICONDATA) -> None: ...
def GetSystemMenu(hwnd: int, bRevert): ...
def DrawMenuBar(hwnd: int) -> None: ...
def MoveWindow(hwnd: int, x, y, width, height, bRepaint) -> None: ...
def MoveWindow(__hwnd: int, __x: int, __y: int, __width: int, __height: int, __bRepaint: bool) -> None: ...
def CloseWindow() -> None: ...
def DeleteMenu(hmenu, position, flags) -> None: ...
def RemoveMenu(hmenu, position, flags) -> None: ...
@@ -200,8 +217,8 @@ def GradientFill(hdc, Vertex: tuple[_win32typing.PyTRIVERTEX, ...], Mesh, Mode)
def GetOpenFileName(OPENFILENAME: str): ...
def InsertMenuItem(hMenu, uItem, fByPosition, menuItem) -> None: ...
def SetMenuItemInfo(hMenu, uItem, fByPosition, menuItem) -> None: ...
def GetMenuItemInfo(hMenu, uItem, fByPosition, menuItem) -> None: ...
def GetMenuItemCount(hMenu): ...
def GetMenuItemInfo(__hMenu: int, __uItem: int, __fByPosition: bool, __menuItem: ReadableBuffer) -> None: ...
def GetMenuItemCount(__hMenu: int | None) -> int: ...
# Actually returns a list of int|tuple, but lists don't support positional types
def GetMenuItemRect(__hWnd: int | None, __hMenu: int | None, __uItem: int) -> tuple[int, tuple[int, int, int, int]]: ...
@@ -220,7 +237,7 @@ def SetMenuItemBitmaps(
) -> None: ...
def CheckMenuRadioItem(hMenu, idFirst, idLast, idCheck, uFlags) -> None: ...
def SetMenuInfo(hmenu, info) -> None: ...
def GetMenuInfo(hmenu, info) -> None: ...
def GetMenuInfo(__hmenu: int, __info: WriteableBuffer) -> None: ...
def DrawFocusRect(hDC: int, rc: tuple[int, int, int, int]) -> None: ...
def DrawText(hDC: int, String, nCount, Rect: _win32typing.PyRECT, Format) -> tuple[Incomplete, _win32typing.PyRECT]: ...
def LineTo(hdc: int, XEnd, YEnd) -> None: ...
@@ -321,10 +338,10 @@ def CreateWindowEx(
dwExStyle, className: str, windowTitle: str, style, x, y, width, height, parent, menu, hinstance, reserved
): ...
def GetParent(child: int) -> int: ...
def SetParent(child: int, child1: int): ...
def SetParent(__child: int, __child1: int | None | _win32typing.PyHANDLE) -> int: ...
def GetCursorPos() -> tuple[Incomplete, Incomplete]: ...
def GetDesktopWindow(): ...
def GetWindow(hWnd: int, uCmd): ...
def GetWindow(__hWnd: int, __uCmd: int) -> int: ...
def GetWindowDC(hWnd: int) -> int: ...
def IsIconic(__hWnd: int) -> int: ...
def IsWindow(__hWnd: int) -> int: ...
@@ -341,7 +358,7 @@ def ScrollWindowEx(
def SetScrollInfo(hwnd: int, nBar, scollInfo: _win32typing.PySCROLLINFO, bRedraw=...) -> None: ...
def GetScrollInfo(hwnd: int, nBar, mask) -> _win32typing.PySCROLLINFO: ...
def GetClassName(hwnd: int) -> str: ...
def WindowFromPoint(point: tuple[Incomplete, Incomplete]): ...
def WindowFromPoint(point: tuple[int, int]) -> int: ...
def ChildWindowFromPoint(hwndParent: int, point: tuple[Incomplete, Incomplete]): ...
def CreateDC(Driver: str, Device: str, InitData: _win32typing.PyDEVMODE): ...
def GetSaveFileNameW(
+1 -1
View File
@@ -38,7 +38,7 @@ def GetStartupInfo() -> _win32typing.PySTARTUPINFO: ...
def GetPriorityClass(handle: int): ...
def GetExitCodeThread(handle: int): ...
def GetExitCodeProcess(handle: int): ...
def GetWindowThreadProcessId(hwnd: int) -> tuple[Incomplete, Incomplete]: ...
def GetWindowThreadProcessId(__hwnd: int | None) -> tuple[int, int]: ...
def SetThreadPriority(handle: int, nPriority) -> None: ...
def GetThreadPriority(handle: int): ...
def GetProcessPriorityBoost(Process: int): ...