8000 More pywin32 stub completion (#9308) · python/typeshed@0c3cf8f · GitHub
[go: up one dir, main page]

Skip to content

Commit 0c3cf8f

Browse files
AvasamAlexWaygood
andauthored
More pywin32 stub completion (#9308)
Completed based on usage of the following libraries in mypy_primer: - apprise - comtypes As well as some of the most popular libraries that use both pywin32 and mypy (all over 1k stars on github): - certbot - anki - flexget - monkey - twisted - salt Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent cdf5cc3 commit 0c3cf8f

35 files changed

+552
-292
lines changed

stubs/pywin32/@tests/stubtest_allowlist_win32.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ win32com.client.combrowse
99
win32com.client.tlbrowse
1010

1111
# Utilities to generate python bindings
12-
win32com.client.build
12+
win32com.client.build.*
1313
win32com.client.CLSIDToClass
1414
win32com.client.connect
1515
# "dynamic.CDipatch" is necessary for mypy to not throw AssertionError
1616
win32com.client.dynamic.*
17-
win32com.client.gencache
17+
win32com.client.gencache.*
1818
win32com.client.genpy
1919
win32com.client.makepy
2020
win32com.client.selecttlb

stubs/pywin32/_win32typing.pyi

Lines changed: 79 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Not available at runtime. Contains type definitions that are otherwise not exposed and not part of a specific module.
2-
from _typeshed import Incomplete
3-
from typing_extensions import final
2+
from _typeshed import Incomplete, Self
3+
from collections.abc import Iterable
4+
from typing import overload
5+
from typing_extensions import Literal, final
46

57
class ArgNotFound: ...
68
class PyOleEmpty: ...
@@ -162,13 +164,16 @@ class PRINTER_DEFAULTS:
162164
class PyACL:
163165
def Initialize(self) -> None: ...
164166
def IsValid(self) -> bool: ...
165-
def AddAccessAllowedAce(self, revision, access, sid: PySID, access1, sid1) -> None: ...
166-
def AddAccessAllowedAceEx(self, revision, aceflags, access, sid: PySID) -> None: ...
167+
@overload
168+
def AddAccessAllowedAce(self, __access: int, __sid: PySID) -> None: ...
169+
@overload
170+
def AddAccessAllowedAce(self, __revision: int, __access: int, __sid: PySID) -> None: ...
171+
def AddAccessAllowedAceEx(self, __revision: int, __aceflags: int, __access: int, __sid: PySID) -> None: ...
167172
def AddAccessAllowedObjectAce(
168173
self, AceRevision, AceFlags, AccessMask, ObjectTypeGuid: PyIID, InheritedObjectTypeGuid: PyIID, sid: PySID
169174
) -> None: ...
170-
def AddAccessDeniedAce(self, revision, access, sid: PySID, access1, sid1) -> None: ...
171-
def AddAccessDeniedAceEx(self, revision, aceflags, access, sid: PySID) -> None: ...
175+
def AddAccessDeniedAce(self, __revision: int, __access: int, __sid: PySID, __access1: int, __sid1: PySID) -> None: ...
176+
def AddAccessDeniedAceEx(self, __revision: int, __aceflags: int, __access: int, __sid: PySID) -> None: ...
172177
def AddMandatoryAce(self, AceRevision, AceFlags, MandatoryPolicy, LabelSid: PySID) -> None: ...
173178
def AddAuditAccessAce(self, dwAceRevision, dwAccessMask, sid: PySID, bAuditSuccess, bAuditFailure) -> None: ...
174179
def AddAuditAccessAceEx(self, dwAceRevision, AceFlags, dwAccessMask, sid: PySID, bAuditSuccess, bAuditFailure) -> None: ...
@@ -185,11 +190,13 @@ class PyACL:
185190
) -> None: ...
186191
def GetAclSize(self): ...
187192
def GetAclRevision(self): ...
188-
def GetAceCount(self): ...
189-
def GetAce(self, index): ...
190-
def DeleteAce(self, index) -> None: ...
191-
def GetEffectiveRightsFromAcl(self, trustee: PyTRUSTEE): ...
193+
def GetAceCount(self) -> int: ...
194+
def GetAce(self, __index: int) -> tuple[tuple[int, int], int, PySID]: ...
195+
def DeleteAce(self, __index: int) -> None: ...
196+
def GetEffectiveRightsFromAcl(self, __trustee: PyTRUSTEE | dict[str, int | PySID]) -> int: ...
192197
def GetAuditedPermissionsFromAcl(self, trustee: PyTRUSTEE) -> tuple[Incomplete, Incomplete]: ...
198+
def SetEntriesInAcl(self, __obexpl_list: tuple[dict[str, int | dict[str, int | PySID]], ...]) -> PyACL: ...
199+
def GetExplicitEntriesFromAcl(self) -> tuple[dict[str, int | dict[str, int | PySID]]] | None: ...
193200

194201
class PyBITMAP:
195202
@property
@@ -546,7 +553,7 @@ class PyConsoleScreenBuffer:
546553
def ReadConsole(self, NumberOfCharsToRead): ...
547554
def WriteConsole(self, Buffer): ...
548555
def FlushConsoleInputBuffer(self) -> None: ...
549-
def SetConsoleTextAttribute(self, Attributes) -> None: ...
556+
def SetConsoleTextAttribute(self, __Attributes: int) -> None: ...
550557
def SetConsoleCursorPosition(self, CursorPosition: PyCOORD) -> None: ...
551558
def SetConsoleScreenBufferSize(self, Size: PyCOORD) -> None: ...
552559
def SetConsoleWindowInfo(self, Absolute, ConsoleWindow: PySMALL_RECT) -> None: ...
@@ -566,7 +573,7 @@ class PyConsoleScreenBuffer:
566573
def SetConsoleFont(self, Font) -> None: ...
567574
def SetStdHandle(self, StdHandle) -> None: ...
568575
def SetConsoleDisplayMode(self, Flags, NewScreenBufferDimensions: PyCOORD) -> None: ...
569-
def WriteConsoleInput(self, Buffer: tuple[PyINPUT_RECORD, ...]): ...
576+
def WriteConsoleInput(self, __Buffer: Iterable[PyINPUT_RECORD]): ...
570577
def ReadConsoleInput(self, Length) -> tuple[PyINPUT_RECORD, ...]: ...
571578
def PeekConsoleInput(self, Length) -> tuple[PyINPUT_RECORD, ...]: ...
572579
def GetNumberOfConsoleInputEvents(self): ...
@@ -864,7 +871,7 @@ class PyEventLogRecord:
864871
@property
865872
def StringInserts(self) -> tuple[str, ...]: ...
866873
@property
867-
def Sid(self) -> PySID: ...
874+
def Sid(self) -> PySID | None: ...
868875
@property
869876
def Data(self) -> str: ...
870877
@property
@@ -916,7 +923,7 @@ class PyHANDLE:
916923
def handle(self) -> int: ...
917924
def Close(self) -> None: ...
918925
def close(self) -> None: ...
919-
def Detach(self): ...
926+
def Detach(self: Self) -> Self: ...
920927

921928
@final
922929
class PyHDESK:
@@ -1049,7 +1056,10 @@ class PyHH_WINTYPE:
10491056
def urlJump2(self) -> str: ...
10501057

10511058
class PyHINTERNET: ...
1052-
class PyHKEY: ...
1059+
1060+
class PyHKEY:
1061+
def Close(self): ...
1062+
10531063
class PyHTHEME: ...
10541064

10551065
@final
@@ -1060,36 +1070,25 @@ class PyHWINSTA:
10601070
def Detach(self, *args, **kwargs): ... # incomplete
10611071

10621072
class PyICONINFO: ...
1073+
1074+
@final
10631075
class PyIID: ...
10641076

10651077
@final
10661078
class PyINPUT_RECORD:
1067-
@property
1068-
def EventType(self): ...
1069-
@property
1070-
def KeyDown(self): ...
1071-
@property
1072-
def RepeatCount(self): ...
1073-
@property
1074-
def VirtualKeyCode(self): ...
1075-
@property
1076-
def VirtualScanCode(self): ...
1077-
@property
1078-
def Char(self) -> str: ...
1079-
@property
1080-
def ControlKeyState(self): ...
1081-
@property
1082-
def ButtonState(self): ...
1083-
@property
1084-
def EventFlags(self): ...
1085-
@property
1086-
def MousePosition(self) -> PyCOORD: ...
1087-
@property
1088-
def Size(self) -> PyCOORD: ...
1089-
@property
1090-
def SetFocus(self): ...
1091-
@property
1092-
def CommandId(self): ...
1079+
EventType: int
1080+
KeyDown: int | bool
1081+
RepeatCount: int
1082+
VirtualKeyCode: int
1083+
VirtualScanCode: Incomplete
1084+
Char: str
1085+
ControlKeyState: int
1086+
ButtonState: int
1087+
EventFlags: int
1088+
MousePosition: PyCOORD
1089+
Size: PyCOORD
1090+
SetFocus: Incomplete
1091+
CommandId: Incomplete
10931092

10941093
class PyLOCALGROUP_INFO_0:
10951094
@property
@@ -1206,20 +1205,13 @@ class PyNMHDR:
12061205
class PyNOTIFYICONDATA: ...
12071206

12081207
class PyOVERLAPPED:
1209-
@property
1210-
def Offset(self) -> int: ...
1211-
@property
1212-
def OffsetHigh(self) -> int: ...
1213-
@property
1214-
def object(self): ...
1215-
@property
1216-
def dword(self): ...
1217-
@property
1218-
def hEvent(self) -> int: ...
1219-
@property
1220-
def Internal(self) -> int: ...
1221-
@property
1222-
def InternalHigh(self) -> int: ...
1208+
Offset: int
1209+
OffsetHigh: int
1210+
object: object
1211+
dword: int
1212+
hEvent: int
1213+
Internal: int
1214+
InternalHigh: int
12231215

12241216
class PyOVERLAPPEDReadBuffer: ...
12251217

@@ -1276,24 +1268,23 @@ class PySCROLLINFO: ...
12761268
class PySC_HANDLE: ...
12771269

12781270
class PySECURITY_ATTRIBUTES:
1279-
@property
1280-
def bInheritHandle(self): ...
1281-
@property
1282-
def SECURITY_DESCRIPTOR(self) -> PySECURITY_DESCRIPTOR: ...
1271+
bInheritHandle: int
1272+
SECURITY_DESCRIPTOR: PySECURITY_DESCRIPTOR
12831273

12841274
class PySECURITY_DESCRIPTOR:
12851275
def Initialize(self) -> None: ...
12861276
def GetSecurityDescriptorOwner(self) -> PySID: ...
12871277
def GetSecurityDescriptorDacl(self) -> PyACL: ...
12881278
def GetSecurityDescriptorSacl(self) -> PyACL: ...
12891279
def GetSecurityDescriptorControl(self) -> tuple[Incomplete, Incomplete]: ...
1290-
def SetSecurityDescriptorOwner(self, sid: PySID, bOwnerDefaulted) -> None: ...
1280+
def SetSecurityDescriptorOwner(self, __sid: PySID, __bOwnerDefaulted: int | bool) -> None: ...
12911281
def SetSecurityDescriptorGroup(self, sid: PySID, bOwnerDefaulted): ...
1282+
def SetSecurityDescriptorDacl(self, __bSaclPresent: int | bool, __SACL: PyACL, __bSaclDefaulted: int | bool) -> None: ...
12921283
def SetSecurityDescriptorSacl(self, bSaclPresent, SACL: PyACL, bSaclDefaulted) -> None: ...
1284+
def SetSecurityDescriptorControl(self, ControlBitsOfInterest, ControlBitsToSet) -> None: ...
12931285
def IsValid(self) -> bool: ...
12941286
def GetLength(self) -> None: ...
12951287
def IsSelfRelative(self) -> bool: ...
1296-
def SetSecurityDescriptorControl(self, ControlBitsOfInterest, ControlBitsToSet) -> None: ...
12971288

12981289
class PySERVER_INFO_100:
12991290
@property
@@ -1661,34 +1652,20 @@ class PySMALL_RECT:
16611652
def Bottom(self): ...
16621653

16631654
class PySTARTUPINFO:
1664-
@property
1665-
def dwX(self) -> int: ...
1666-
@property
1667-
def dwY(self) -> int: ...
1668-
@property
1669-
def dwXSize(self) -> int: ...
1670-
@property
1671-
def dwYSize(self) -> int: ...
1672-
@property
1673-
def dwXCountChars(self) -> int: ...
1674-
@property
1675-
def dwYCountChars(self) -> int: ...
1676-
@property
1677-
def dwFillAttribute(self) -> int: ...
1678-
@property
1679-
def dwFlags(self) -> int: ...
1680-
@property
1681-
def wShowWindow(self) -> int: ...
1682-
@property
1683-
def hStdInput(self) -> int: ...
1684-
@property
1685-
def hStdOutput(self) -> int: ...
1686-
@property
1687-
def hStdError(self) -> int: ...
1688-
@property
1689-
def lpDesktop(self) -> str: ...
1690-
@property
1691-
def lpTitle(self) -> str: ...
1655+
dwX: int
1656+
dwY: int
1657+
dwXSize: int
1658+
dwYSize: int
1659+
dwXCountChars: int
1660+
dwYCountChars: int
1661+
dwFillAttribute: int
1662+
dwFlags: int
1663+
wShowWindow: int
1664+
hStdInput: int
1665+
hStdOutput: int
1666+
hStdError: int
1667+
lpDesktop: str
1668+
lpTitle: str
16921669

16931670
class PySecBuffer:
16941671
@property
@@ -1703,6 +1680,7 @@ class PySecBuffer:
17031680

17041681
class PySecBufferDesc:
17051682
Version: Incomplete
1683+
Buffer: Incomplete
17061684
def append(self, buffer) -> None: ...
17071685

17081686
class PyTOKEN_GROUPS: ...
@@ -1722,17 +1700,18 @@ class PyTRIVERTEX:
17221700
@property
17231701
def Alpha(self): ...
17241702

1703+
# Properties Multiple* are ignored
17251704
class PyTRUSTEE:
17261705
@property
1727-
def TrusteeForm(self): ...
1706+
def TrusteeForm(self) -> int: ...
17281707
@property
1729-
def TrusteeType(self): ...
1708+
def TrusteeType(self) -> int: ...
17301709
@property
1731-
def Identifier(self): ...
1710+
def Identifier(self) -> PySID: ...
17321711
@property
1733-
def MultipleTrustee(self): ...
1712+
def MultipleTrustee(self) -> None: ...
17341713
@property
1735-
def MultipleTrusteeOperation(self): ...
1714+
def MultipleTrusteeOperation(self) -> Literal[0]: ...
17361715

17371716
class PyTS_HANDLE: ...
17381717

@@ -2459,7 +2438,9 @@ class SERVICE_FAILURE_ACTIONS:
24592438
@property
24602439
def Actions(self): ...
24612440

2462-
class SERVICE_STATUS: ...
2441+
class SERVICE_STATUS:
2442+
def __getitem__(self, __i: int) -> int: ...
2443+
24632444
class TRACKMOUSEEVENT: ...
24642445
class ULARGE_INTEGER: ...
24652446
class WIN32_FIND_DATA: ...
@@ -3389,6 +3370,7 @@ class PyIDirectorySearch:
33893370
def GetColumn(self, handle, name: str) -> tuple[Incomplete, Incomplete, Incomplete]: ...
33903371
def GetNextColumnName(self) -> None: ...
33913372

3373+
@final
33923374
class PyIDispatch:
33933375
def Invoke(self, dispid, lcid, flags, bResultWanted, arg: tuple[Incomplete, ...]): ...
33943376
def InvokeTypes(
@@ -4679,6 +4661,7 @@ class PyIUniformResourceLocator:
46794661
def SetURL(self, URL, InFlags: int = ...) -> None: ...
46804662
def InvokeCommand(self, Verb, Flags: int = ..., hwndParent: int = ...): ...
46814663

4664+
@final
46824665
class PyIUnknown:
46834666
def QueryInterface(self, iid, useIID: Incomplete | None = ...) -> PyIUnknown: ...
46844667

@@ -5788,7 +5771,7 @@ class PyCWinApp:
57885771
def LoadCursor(self, cursorId: PyResourceId): ...
57895772
def LoadStandardCursor(self, cursorId: PyResourceId): ...
57905773
def LoadOEMCursor(self, cursorId): ...
5791-
def LoadIcon(self, idResource): ...
5774+
def LoadIcon(self, idResource: int) -> int: ...
57925775
def LoadStandardIcon(self, resourceName: PyResourceId): ...
57935776
def OpenDocumentFile(self, fileName: str) -> None: ...
57945777
def OnFileNew(self) -> None: ...

stubs/pywin32/pythoncom.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def CoCreateInstanceEx(
2020
iids: list[_win32typing.PyIID],
2121
) -> _win32typing.PyIUnknown: ...
2222
def CoCreateInstance(
23-
clsid: _win32typing.PyIID, unkOuter: _win32typing.PyIUnknown, context, iid: _win32typing.PyIID
23+
__clsid: _win32typing.PyIID, __unkOuter: _win32typing.PyIUnknown | None, __context: int, __iid: _win32typing.PyIID
2424
) -> _win32typing.PyIUnknown: ...
2525
def CoFreeUnusedLibraries() -> None: ...
2626
def CoInitialize() -> None: ...
@@ -84,7 +84,7 @@ def OleLoadFromStream(stream: _win32typing.PyIStream, iid: _win32typing.PyIID) -
8484
def OleSaveToStream(persist: _win32typing.PyIPersistStream, stream: _win32typing.PyIStream) -> None: ...
8585
def OleLoad(storage: _win32typing.PyIStorage, iid: _win32typing.PyIID, site: _win32typing.PyIOleClientSite) -> None: ...
8686
def ProgIDFromCLSID(clsid) -> str: ...
87-
def PumpWaitingMessages(): ...
87+
def PumpWaitingMessages(__firstMessage: int = ..., __lastMessage: int = ...) -> int: ...
8888
def PumpMessages() -> None: ...
8989
def QueryPathOfRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid) -> str: ...
9090
def ReadClassStg(storage: _win32typing.PyIStorage) -> _win32typing.PyIID: ...

stubs/pywin32/pythonwin/win32ui.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def MessageBox(message: str, arg, title: str | None = ...): ...
122122
def OutputDebugString(msg: str) -> None: ...
123123
def EnableControlContainer(): ...
124124
def PrintTraceback(tb, output) -> None: ...
125-
def PumpWaitingMessages(firstMessage, lastMessage): ...
125+
def PumpWaitingMessages(__firstMessage: int = ..., __lastMessage: int = ...) -> int: ...
126126
def RegisterWndClass(style, hCursor: int = ..., hBrush: int = ..., hIcon=...) -> str: ...
127127
def RemoveRecentFile(index: int = ...) -> None: ...
128128
def SetAppHelpPath(): ...

0 commit comments

Comments
 (0)
0