Skip to content

Commit 5265263

Browse files
authored
Type stub for win32com.server (#14492)
1 parent ecb0742 commit 5265263

File tree

5 files changed

+88
-5
lines changed

5 files changed

+88
-5
lines changed

stubs/pywin32/@tests/stubtest_allowlist_win32.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ win32com.makegw.*
2222
(win32.lib.)?pywintypes.__import_pywin32_system_module__
2323

2424
# COM object servers scripts
25-
win32com.server.factory
26-
win32com.server.localserver
27-
win32com.server.register
2825
win32com.servers.*
2926
# Active X Scripts
3027
win32com(ext)?.axscript.client.pyscript_rexec

stubs/pywin32/pythoncom.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def CoUnmarshalInterface(Stm: _win32typing.PyIStream, riid: _win32typing.PyIID,
4747
def CoReleaseMarshalData(Stm: _win32typing.PyIStream, /) -> None: ...
4848
def CoGetObject(name: str, iid: _win32typing.PyIID, bindOpts: Incomplete | None = ..., /) -> _win32typing.PyIUnknown: ...
4949
def CoUninitialize() -> None: ...
50-
def CoRegisterClassObject(iid: _win32typing.PyIID, factory: _win32typing.PyIUnknown, context, flags, /): ...
50+
def CoRegisterClassObject(iid: _win32typing.PyIID, factory: _win32typing.PyIUnknown, context, flags, /) -> int: ...
5151
def CoResumeClassObjects() -> None: ...
52-
def CoRevokeClassObject(reg, /) -> None: ...
52+
def CoRevokeClassObject(reg: int, /) -> None: ...
5353
def CoTreatAsClass(clsidold: _win32typing.PyIID, clsidnew: _win32typing.PyIID, /) -> None: ...
5454
def CoWaitForMultipleHandles(Flags, Timeout, Handles: list[int], /): ...
5555
def Connect(cls, /) -> _win32typing.PyIDispatch: ...
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from _typeshed import Unused
2+
from collections.abc import Iterable
3+
4+
from _win32typing import PyIClassFactory, PyIID
5+
6+
def RegisterClassFactories(
7+
clsids: Iterable[PyIID], flags: int | None = None, clsctx: int | None = None
8+
) -> list[tuple[PyIClassFactory, int]]: ...
9+
def RevokeClassFactories(infos: Iterable[tuple[Unused, int]]) -> None: ...
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from collections.abc import Iterable
2+
from typing import Final
3+
4+
from _win32typing import PyIID
5+
6+
usage: Final[str]
7+
8+
def serve(clsids: Iterable[PyIID]) -> None: ...
9+
def main() -> None: ...
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from collections.abc import Callable, Iterable, Mapping
2+
from typing import Final, Literal, Protocol, TypedDict, TypeVar, type_check_only
3+
from typing_extensions import Unpack
4+
5+
from _win32typing import PyHKEY, PyIID
6+
7+
_T = TypeVar("_T", PyHKEY, int)
8+
9+
@type_check_only
10+
class _RegisterClass(Protocol):
11+
_reg_clsid_: PyIID
12+
13+
@type_check_only
14+
class _RegisterFlag(TypedDict, total=False):
15+
quiet: bool
16+
debug: bool
17+
finalize_register: Callable[[], None]
18+
19+
@type_check_only
20+
class _UnregisterFlag(TypedDict, total=False):
21+
quiet: bool
22+
finalize_unregister: Callable[[], None]
23+
24+
@type_check_only
25+
class _ElevatedFlag(TypedDict, total=False):
26+
quiet: bool
27+
unattended: bool
28+
hwnd: int
29+
30+
@type_check_only
31+
class _CommandFlag(_RegisterFlag, _UnregisterFlag, _ElevatedFlag): # type: ignore[misc]
32+
...
33+
34+
CATID_PythonCOMServer: Final = "{B3EF80D0-68E2-11D0-A689-00C04FD658FF}"
35+
36+
def recurse_delete_key(path: str | None, base: PyHKEY | int = -2147483648) -> None: ...
37+
def RegisterServer(
38+
clsid: PyIID,
39+
pythonInstString: str | None = None,
40+
desc: str | None = None,
41+
progID: str | None = None,
42+
verProgID: str | None = None,
43+
defIcon: str | None = None,
44+
threadingModel: Literal["apartment", "both", "free", "neutral"] = "both",
45+
policy: str | None = None,
46+
catids: list[PyIID] = [],
47+
other: Mapping[str, str] = {},
48+
addPyComCat: bool | None = None,
49+
dispatcher: str | None = None,
50+
clsctx: int | None = None,
51+
addnPath: str | None = None,
52+
) -> None: ...
53+
def GetUnregisterServerKeys(
54+
clsid: PyIID, progID: str | None = None, verProgID: str | None = None, customKeys: Iterable[tuple[str, _T]] | None = None
55+
) -> list[tuple[str, _T | int]]: ...
56+
def UnregisterServer(
57+
clsid: PyIID,
58+
progID: str | None = None,
59+
verProgID: str | None = None,
60+
customKeys: Iterable[tuple[str, PyHKEY | int]] | None = None,
61+
) -> None: ...
62+
def GetRegisteredServerOption(clsid: PyIID, optionName: str) -> str | None: ...
63+
def RegisterClasses(*classes: type[_RegisterClass], **flags: Unpack[_RegisterFlag]) -> None: ...
64+
def UnregisterClasses(*classes: type[_RegisterClass], **flags: Unpack[_UnregisterFlag]) -> None: ...
65+
def UnregisterInfoClasses(*classes: type[_RegisterClass]) -> list[tuple[str, PyHKEY | int]]: ...
66+
def ReExecuteElevated(flags: _ElevatedFlag) -> None: ...
67+
def UseCommandLine(*classes: type[_RegisterClass], **flags: Unpack[_CommandFlag]) -> list[tuple[str, PyHKEY | int]] | None: ...
68+
def RegisterPyComCategory() -> None: ...

0 commit comments

Comments
 (0)