Skip to content

Commit 0b8841e

Browse files
authored
pywin32: Use PEP 570 positional-only argument syntax and fix arguments (#11321)
1 parent d3b45a4 commit 0b8841e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2965
-2886
lines changed

stubs/pywin32/@tests/stubtest_allowlist_win32.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ win32com.axdebug.gateways
7272
win32comext.axdebug.gateways
7373
# failed to import, ModuleNotFoundError: No module named 'win32comext.axdebug.axdebug'
7474
win32comext.axdebug.axdebug
75+
76+
# Stubtest doesn't agree with win32.lib.pywintypes.error.__init__ being positional-only
77+
.+?\.error.__init__

stubs/pywin32/_win32typing.pyi

Lines changed: 1479 additions & 1456 deletions
Large diffs are not rendered by default.

stubs/pywin32/pythoncom.pyi

Lines changed: 73 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,103 +11,105 @@ error: TypeAlias = com_error # noqa: Y042
1111

1212
class internal_error(Exception): ...
1313

14-
def CoCreateFreeThreadedMarshaler(unk: _win32typing.PyIUnknown) -> _win32typing.PyIUnknown: ...
14+
def CoCreateFreeThreadedMarshaler(unk: _win32typing.PyIUnknown, /) -> _win32typing.PyIUnknown: ...
1515
def CoCreateInstanceEx(
1616
clsid: _win32typing.PyIID,
1717
unkOuter: _win32typing.PyIUnknown,
1818
context,
1919
serverInfo: tuple[Incomplete, Incomplete, Incomplete, Incomplete],
2020
iids: list[_win32typing.PyIID],
21+
/,
2122
) -> _win32typing.PyIUnknown: ...
2223
def CoCreateInstance(
23-
__clsid: _win32typing.PyIID, __unkOuter: _win32typing.PyIUnknown | None, __context: int, __iid: _win32typing.PyIID
24+
clsid: _win32typing.PyIID, unkOuter: _win32typing.PyIUnknown | None, context: int, iid: _win32typing.PyIID, /
2425
) -> _win32typing.PyIUnknown: ...
2526
def CoFreeUnusedLibraries() -> None: ...
2627
def CoInitialize() -> None: ...
27-
def CoInitializeEx(flags) -> None: ...
28+
def CoInitializeEx(flags, /) -> None: ...
2829
def CoInitializeSecurity(
29-
sd: _win32typing.PySECURITY_DESCRIPTOR, authSvc, reserved1, authnLevel, impLevel, authInfo, capabilities, reserved2
30+
sd: _win32typing.PySECURITY_DESCRIPTOR, authSvc, reserved1, authnLevel, impLevel, authInfo, capabilities, reserved2, /
3031
) -> None: ...
31-
def CoGetInterfaceAndReleaseStream(stream: _win32typing.PyIStream, iid: _win32typing.PyIID) -> _win32typing.PyIUnknown: ...
32-
def CoMarshalInterThreadInterfaceInStream(iid: _win32typing.PyIID, unk: _win32typing.PyIUnknown) -> _win32typing.PyIStream: ...
32+
def CoGetInterfaceAndReleaseStream(stream: _win32typing.PyIStream, iid: _win32typing.PyIID, /) -> _win32typing.PyIUnknown: ...
33+
def CoMarshalInterThreadInterfaceInStream(iid: _win32typing.PyIID, unk: _win32typing.PyIUnknown, /) -> _win32typing.PyIStream: ...
3334
def CoMarshalInterface(
34-
Stm: _win32typing.PyIStream, riid: _win32typing.PyIID, Unk: _win32typing.PyIUnknown, DestContext, flags
35+
Stm: _win32typing.PyIStream, riid: _win32typing.PyIID, Unk: _win32typing.PyIUnknown, DestContext, flags, /
3536
) -> None: ...
36-
def CoUnmarshalInterface(Stm: _win32typing.PyIStream, riid: _win32typing.PyIID): ...
37-
def CoReleaseMarshalData(Stm: _win32typing.PyIStream) -> None: ...
38-
def CoGetObject(name: str, iid: _win32typing.PyIID, bindOpts: Incomplete | None = ...) -> _win32typing.PyIUnknown: ...
37+
def CoUnmarshalInterface(Stm: _win32typing.PyIStream, riid: _win32typing.PyIID, /): ...
38+
def CoReleaseMarshalData(Stm: _win32typing.PyIStream, /) -> None: ...
39+
def CoGetObject(name: str, iid: _win32typing.PyIID, bindOpts: Incomplete | None = ..., /) -> _win32typing.PyIUnknown: ...
3940
def CoUninitialize() -> None: ...
40-
def CoRegisterClassObject(iid: _win32typing.PyIID, factory: _win32typing.PyIUnknown, context, flags): ...
41+
def CoRegisterClassObject(iid: _win32typing.PyIID, factory: _win32typing.PyIUnknown, context, flags, /): ...
4142
def CoResumeClassObjects() -> None: ...
42-
def CoRevokeClassObject(reg) -> None: ...
43-
def CoTreatAsClass(clsidold: _win32typing.PyIID, clsidnew: _win32typing.PyIID) -> None: ...
44-
def CoWaitForMultipleHandles(Flags, Timeout, Handles: list[int]): ...
45-
def Connect(cls) -> _win32typing.PyIDispatch: ...
43+
def CoRevokeClassObject(reg, /) -> None: ...
44+
def CoTreatAsClass(clsidold: _win32typing.PyIID, clsidnew: _win32typing.PyIID, /) -> None: ...
45+
def CoWaitForMultipleHandles(Flags, Timeout, Handles: list[int], /): ...
46+
def Connect(cls, /) -> _win32typing.PyIDispatch: ...
4647
def CreateGuid() -> _win32typing.PyIID: ...
4748
def CreateBindCtx() -> _win32typing.PyIBindCtx: ...
48-
def CreateFileMoniker(filename: str) -> _win32typing.PyIMoniker: ...
49-
def CreateItemMoniker(delim: str, item: str) -> _win32typing.PyIMoniker: ...
50-
def CreatePointerMoniker(IUnknown: _win32typing.PyIUnknown) -> _win32typing.PyIMoniker: ...
49+
def CreateFileMoniker(filename: str, /) -> _win32typing.PyIMoniker: ...
50+
def CreateItemMoniker(delim: str, item: str, /) -> _win32typing.PyIMoniker: ...
51+
def CreatePointerMoniker(IUnknown: _win32typing.PyIUnknown, /) -> _win32typing.PyIMoniker: ...
5152
def CreateTypeLib(): ...
5253
def CreateTypeLib2(): ...
53-
def CreateStreamOnHGlobal(hGlobal: int | None = ..., DeleteOnRelease: bool = ...) -> _win32typing.PyIStream: ...
54-
def CreateILockBytesOnHGlobal(hGlobal: int | None = ..., DeleteOnRelease: bool = ...) -> _win32typing.PyILockBytes: ...
55-
def EnableQuitMessage(threadId) -> None: ...
54+
def CreateStreamOnHGlobal(hGlobal: int | None = ..., DeleteOnRelease: bool = ..., /) -> _win32typing.PyIStream: ...
55+
def CreateILockBytesOnHGlobal(hGlobal: int | None = ..., DeleteOnRelease: bool = ..., /) -> _win32typing.PyILockBytes: ...
56+
def EnableQuitMessage(threadId, /) -> None: ...
5657
def FUNCDESC() -> _win32typing.FUNCDESC: ...
57-
def GetActiveObject(cls) -> _win32typing.PyIUnknown: ...
58-
def GetClassFile(fileName) -> _win32typing.PyIID: ...
59-
def GetFacilityString(scode) -> str: ...
58+
def GetActiveObject(cls, /) -> _win32typing.PyIUnknown: ...
59+
def GetClassFile(fileName, /) -> _win32typing.PyIID: ...
60+
def GetFacilityString(scode, /) -> str: ...
6061
def GetRecordFromGuids(
61-
iid: _win32typing.PyIID, verMajor, verMinor, lcid, infoIID: _win32typing.PyIID, data: Incomplete | None = ...
62+
iid: _win32typing.PyIID, verMajor, verMinor, lcid, infoIID: _win32typing.PyIID, data: Incomplete | None = ..., /
6263
): ...
63-
def GetRecordFromTypeInfo(TypeInfo: _win32typing.PyITypeInfo): ...
64-
def GetRunningObjectTable(reserved: int = ...) -> _win32typing.PyIRunningObjectTable: ...
65-
def GetScodeString(scode) -> str: ...
66-
def GetScodeRangeString(scode) -> str: ...
67-
def GetSeverityString(scode) -> str: ...
68-
def IsGatewayRegistered(__iid: _win32typing.PyIID | None) -> int: ...
69-
def LoadRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid) -> _win32typing.PyITypeLib: ...
70-
def LoadTypeLib(libFileName: str) -> _win32typing.PyITypeLib: ...
71-
def MakePyFactory(iid: _win32typing.PyIID) -> _win32typing.PyIClassFactory: ...
64+
def GetRecordFromTypeInfo(TypeInfo: _win32typing.PyITypeInfo, /): ...
65+
def GetRunningObjectTable(reserved: int = ..., /) -> _win32typing.PyIRunningObjectTable: ...
66+
def GetScodeString(scode, /) -> str: ...
67+
def GetScodeRangeString(scode, /) -> str: ...
68+
def GetSeverityString(scode, /) -> str: ...
69+
def IsGatewayRegistered(iid: _win32typing.PyIID | None, /) -> int: ...
70+
def LoadRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid, /) -> _win32typing.PyITypeLib: ...
71+
def LoadTypeLib(libFileName: str, /) -> _win32typing.PyITypeLib: ...
72+
def MakePyFactory(iid: _win32typing.PyIID, /) -> _win32typing.PyIClassFactory: ...
7273
def MkParseDisplayName(
73-
displayName: str, bindCtx: _win32typing.PyIBindCtx | None = ...
74+
displayName: str, bindCtx: _win32typing.PyIBindCtx | None = ..., /
7475
) -> tuple[_win32typing.PyIMoniker, Incomplete, _win32typing.PyIBindCtx]: ...
75-
def New(cls) -> _win32typing.PyIDispatch: ...
76-
def ObjectFromAddress(address, iid: _win32typing.PyIID) -> _win32typing.PyIUnknown: ...
77-
def ObjectFromLresult(lresult, iid: _win32typing.PyIID, wparm) -> _win32typing.PyIUnknown: ...
76+
def New(cls, /) -> _win32typing.PyIDispatch: ...
77+
def ObjectFromAddress(address, iid: _win32typing.PyIID, /) -> _win32typing.PyIUnknown: ...
78+
def ObjectFromLresult(lresult, iid: _win32typing.PyIID, wparm, /) -> _win32typing.PyIUnknown: ...
7879
def OleInitialize() -> None: ...
7980
def OleGetClipboard() -> _win32typing.PyIDataObject: ...
8081
def OleFlushClipboard() -> None: ...
81-
def OleIsCurrentClipboard(dataObj: _win32typing.PyIDataObject): ...
82-
def OleSetClipboard(dataObj: _win32typing.PyIDataObject) -> None: ...
83-
def OleLoadFromStream(stream: _win32typing.PyIStream, iid: _win32typing.PyIID) -> None: ...
84-
def OleSaveToStream(persist: _win32typing.PyIPersistStream, stream: _win32typing.PyIStream) -> None: ...
85-
def OleLoad(storage: _win32typing.PyIStorage, iid: _win32typing.PyIID, site: _win32typing.PyIOleClientSite) -> None: ...
86-
def ProgIDFromCLSID(clsid) -> str: ...
87-
def PumpWaitingMessages(__firstMessage: int = ..., __lastMessage: int = ...) -> int: ...
82+
def OleIsCurrentClipboard(dataObj: _win32typing.PyIDataObject, /): ...
83+
def OleSetClipboard(dataObj: _win32typing.PyIDataObject, /) -> None: ...
84+
def OleLoadFromStream(stream: _win32typing.PyIStream, iid: _win32typing.PyIID, /) -> None: ...
85+
def OleSaveToStream(persist: _win32typing.PyIPersistStream, stream: _win32typing.PyIStream, /) -> None: ...
86+
def OleLoad(storage: _win32typing.PyIStorage, iid: _win32typing.PyIID, site: _win32typing.PyIOleClientSite, /) -> None: ...
87+
def ProgIDFromCLSID(clsid, /) -> str: ...
88+
def PumpWaitingMessages(firstMessage: int = ..., lastMessage: int = ..., /) -> int: ...
8889
def PumpMessages() -> None: ...
89-
def QueryPathOfRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid) -> str: ...
90-
def ReadClassStg(storage: _win32typing.PyIStorage) -> _win32typing.PyIID: ...
91-
def ReadClassStm(Stm: _win32typing.PyIStream) -> _win32typing.PyIID: ...
92-
def RegisterTypeLib(typelib: _win32typing.PyITypeLib, fullPath: str, lcid, helpDir: str | None = ...) -> None: ...
93-
def UnRegisterTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid, syskind) -> str: ...
94-
def RegisterActiveObject(obUnknown: _win32typing.PyIUnknown, clsid: _win32typing.PyIID, flags): ...
95-
def RevokeActiveObject(handle) -> None: ...
96-
def RegisterDragDrop(hwnd: int, dropTarget: _win32typing.PyIDropTarget) -> None: ...
97-
def RevokeDragDrop(hwnd: int) -> None: ...
90+
def QueryPathOfRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid, /) -> str: ...
91+
def ReadClassStg(storage: _win32typing.PyIStorage, /) -> _win32typing.PyIID: ...
92+
def ReadClassStm(Stm: _win32typing.PyIStream, /) -> _win32typing.PyIID: ...
93+
def RegisterTypeLib(typelib: _win32typing.PyITypeLib, fullPath: str, lcid, helpDir: str | None = ..., /) -> None: ...
94+
def UnRegisterTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid, syskind, /) -> str: ...
95+
def RegisterActiveObject(obUnknown: _win32typing.PyIUnknown, clsid: _win32typing.PyIID, flags, /): ...
96+
def RevokeActiveObject(handle, /) -> None: ...
97+
def RegisterDragDrop(hwnd: int, dropTarget: _win32typing.PyIDropTarget, /) -> None: ...
98+
def RevokeDragDrop(hwnd: int, /) -> None: ...
9899
def DoDragDrop() -> None: ...
99-
def StgCreateDocfile(name: str, mode, reserved: int = ...) -> _win32typing.PyIStorage: ...
100-
def StgCreateDocfileOnILockBytes(lockBytes: _win32typing.PyILockBytes, mode, reserved=...) -> _win32typing.PyIStorage: ...
100+
def StgCreateDocfile(name: str, mode, reserved: int = ..., /) -> _win32typing.PyIStorage: ...
101+
def StgCreateDocfileOnILockBytes(lockBytes: _win32typing.PyILockBytes, mode, reserved=..., /) -> _win32typing.PyIStorage: ...
101102
def StgOpenStorageOnILockBytes(
102103
lockBytes: _win32typing.PyILockBytes,
103104
stgPriority: _win32typing.PyIStorage,
104105
snbExclude: Incomplete | None = ...,
105106
reserved: int = ...,
107+
/,
106108
) -> _win32typing.PyIStorage: ...
107-
def StgIsStorageFile(name: str): ...
109+
def StgIsStorageFile(name: str, /): ...
108110
def STGMEDIUM() -> _win32typing.PySTGMEDIUM: ...
109111
def StgOpenStorage(
110-
name: str, other: _win32typing.PyIStorage, mode, snbExclude: Incomplete | None = ..., reserved=...
112+
name: str, other: _win32typing.PyIStorage, mode, snbExclude: Incomplete | None = ..., reserved=..., /
111113
) -> _win32typing.PyIStorage: ...
112114
def StgOpenStorageEx(
113115
Name: str, Mode, stgfmt, Attrs, riid: _win32typing.PyIID, StgOptions: Incomplete | None = ...
@@ -123,20 +125,20 @@ def StgCreateStorageEx(
123125
) -> _win32typing.PyIStorage: ...
124126
def TYPEATTR() -> _win32typing.TYPEATTR: ...
125127
def VARDESC() -> _win32typing.VARDESC: ...
126-
def WrapObject(ob, gatewayIID: _win32typing.PyIID, interfaceIID: _win32typing.PyIID) -> _win32typing.PyIUnknown: ...
127-
def WriteClassStg(storage: _win32typing.PyIStorage, iid: _win32typing.PyIID) -> None: ...
128-
def WriteClassStm(Stm: _win32typing.PyIStream, clsid: _win32typing.PyIID) -> None: ...
129-
def UnwrapObject(ob: _win32typing.PyIUnknown) -> _win32typing.PyIDispatch: ...
130-
def FmtIdToPropStgName(fmtid: _win32typing.PyIID): ...
131-
def PropStgNameToFmtId(Name: str) -> _win32typing.PyIID: ...
132-
def CoGetCallContext(riid: _win32typing.PyIID) -> _win32typing.PyIServerSecurity: ...
133-
def CoGetObjectContext(riid: _win32typing.PyIID) -> _win32typing.PyIContext: ...
134-
def CoGetCancelObject(riid: _win32typing.PyIID, ThreadID: int = ...) -> _win32typing.PyICancelMethodCalls: ...
135-
def CoSetCancelObject(Unk: _win32typing.PyIUnknown) -> None: ...
128+
def WrapObject(ob, gatewayIID: _win32typing.PyIID, interfaceIID: _win32typing.PyIID, /) -> _win32typing.PyIUnknown: ...
129+
def WriteClassStg(storage: _win32typing.PyIStorage, iid: _win32typing.PyIID, /) -> None: ...
130+
def WriteClassStm(Stm: _win32typing.PyIStream, clsid: _win32typing.PyIID, /) -> None: ...
131+
def UnwrapObject(ob: _win32typing.PyIUnknown, /) -> _win32typing.PyIDispatch: ...
132+
def FmtIdToPropStgName(fmtid: _win32typing.PyIID, /): ...
133+
def PropStgNameToFmtId(Name: str, /) -> _win32typing.PyIID: ...
134+
def CoGetCallContext(riid: _win32typing.PyIID, /) -> _win32typing.PyIServerSecurity: ...
135+
def CoGetObjectContext(riid: _win32typing.PyIID, /) -> _win32typing.PyIContext: ...
136+
def CoGetCancelObject(riid: _win32typing.PyIID, ThreadID: int = ..., /) -> _win32typing.PyICancelMethodCalls: ...
137+
def CoSetCancelObject(Unk: _win32typing.PyIUnknown, /) -> None: ...
136138
def CoEnableCallCancellation() -> None: ...
137139
def CoDisableCallCancellation() -> None: ...
138-
def CreateURLMonikerEx(*args, **kwargs): ... # incomplete
139-
def new(__iid: _win32typing.PyIID | str): ...
140+
def CreateURLMonikerEx(*args): ... # incomplete
141+
def new(iid: _win32typing.PyIID | str, /): ...
140142

141143
ACTIVEOBJECT_STRONG: int
142144
ACTIVEOBJECT_WEAK: int
@@ -446,7 +448,7 @@ VT_VARIANT: int
446448
VT_VECTOR: int
447449
VT_VOID: int
448450

449-
def connect(*args, **kwargs): ... # incomplete
451+
def connect(*args): ... # incomplete
450452

451453
dcom: int
452454
fdexNameCaseInsensitive: int

stubs/pywin32/pythonwin/dde.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ CBF_SKIP_CONNECT_CONFIRMS: int
1616
CBF_SKIP_DISCONNECTS: int
1717
CBF_SKIP_REGISTRATIONS: int
1818

19-
def CreateConversation(*args, **kwargs): ... # incomplete
20-
def CreateServer(*args, **kwargs): ... # incomplete
21-
def CreateServerSystemTopic(*args, **kwargs): ... # incomplete
22-
def CreateStringItem(*args, **kwargs): ... # incomplete
23-
def CreateTopic(*args, **kwargs): ... # incomplete
19+
def CreateConversation(*args): ... # incomplete
20+
def CreateServer(*args): ... # incomplete
21+
def CreateServerSystemTopic(*args): ... # incomplete
22+
def CreateStringItem(*args): ... # incomplete
23+
def CreateTopic(*args): ... # incomplete
2424

2525
MF_CALLBACKS: int
2626
MF_CONV: int

0 commit comments

Comments
 (0)