mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-24 09:18:40 +08:00
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>
This commit is contained in:
@@ -1,25 +1,29 @@
|
||||
from _typeshed import Incomplete
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from win32com.client import dynamic as dynamic
|
||||
import _win32typing
|
||||
from win32com.client import dynamic as dynamic, gencache as gencache
|
||||
|
||||
_Stringifiable: TypeAlias = object
|
||||
|
||||
def GetObject(Pathname: str | None = ..., Class: Incomplete | None = ..., clsctx: Incomplete | None = ...) -> CDispatch: ...
|
||||
def GetActiveObject(Class, clsctx=...): ...
|
||||
def Moniker(Pathname, clsctx=...): ...
|
||||
def Dispatch(
|
||||
dispatch,
|
||||
userName: Incomplete | None = ...,
|
||||
resultCLSID: Incomplete | None = ...,
|
||||
typeinfo: Incomplete | None = ...,
|
||||
UnicodeToString: Incomplete | None = ...,
|
||||
clsctx=...,
|
||||
): ...
|
||||
dispatch: str | dynamic.PyIDispatchType | dynamic._GoodDispatchTypes | dynamic.PyIUnknownType,
|
||||
userName: str | None = ...,
|
||||
resultCLSID: _Stringifiable | None = ...,
|
||||
typeinfo: _win32typing.PyITypeInfo | None = ...,
|
||||
UnicodeToString: None = ...,
|
||||
clsctx: int = ...,
|
||||
) -> dynamic.CDispatch: ...
|
||||
def DispatchEx(
|
||||
clsid,
|
||||
machine: Incomplete | None = ...,
|
||||
userName: Incomplete | None = ...,
|
||||
resultCLSID: Incomplete | None = ...,
|
||||
typeinfo: Incomplete | None = ...,
|
||||
UnicodeToString: Incomplete | None = ...,
|
||||
UnicodeToString: None = ...,
|
||||
clsctx: Incomplete | None = ...,
|
||||
): ...
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
from _typeshed import Incomplete
|
||||
|
||||
class OleItem:
|
||||
typename: str
|
||||
doc: Incomplete
|
||||
python_name: Incomplete
|
||||
bWritten: int
|
||||
bIsDispatch: int
|
||||
bIsSink: int
|
||||
clsid: Incomplete
|
||||
co_class: Incomplete
|
||||
def __init__(self, doc: Incomplete | None = ...) -> None: ...
|
||||
|
||||
class DispatchItem(OleItem):
|
||||
typename: str
|
||||
propMap: Incomplete
|
||||
propMapGet: Incomplete
|
||||
propMapPut: Incomplete
|
||||
mapFuncs: Incomplete
|
||||
defaultDispatchName: Incomplete
|
||||
hidden: int
|
||||
def __init__(
|
||||
self, typeinfo: Incomplete | None = ..., attr: Incomplete | None = ..., doc: Incomplete | None = ..., bForUser: int = ...
|
||||
) -> None: ...
|
||||
clsid: Incomplete
|
||||
bIsDispatch: Incomplete
|
||||
def Build(self, typeinfo, attr, bForUser: int = ...) -> None: ...
|
||||
def CountInOutOptArgs(self, argTuple): ...
|
||||
def MakeFuncMethod(self, entry, name, bMakeClass: int = ...): ...
|
||||
def MakeDispatchFuncMethod(self, entry, name, bMakeClass: int = ...): ...
|
||||
def MakeVarArgsFuncMethod(self, entry, name, bMakeClass: int = ...): ...
|
||||
|
||||
class LazyDispatchItem(DispatchItem):
|
||||
typename: str
|
||||
clsid: Incomplete
|
||||
def __init__(self, attr, doc) -> None: ...
|
||||
@@ -1,14 +1,73 @@
|
||||
from _typeshed import Incomplete
|
||||
from typing import Any
|
||||
from typing import Any, Protocol, TypeVar, overload
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
import _win32typing
|
||||
from win32.lib.pywintypes import IIDType
|
||||
from win32com.client import build as build
|
||||
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class _DispatchCreateClass(Protocol[_T_co]):
|
||||
@staticmethod
|
||||
def __call__(
|
||||
IDispatch: str | PyIDispatchType | _GoodDispatchTypes | PyIUnknownType,
|
||||
olerepr: build.DispatchItem | build.LazyDispatchItem,
|
||||
userName: str | None = ...,
|
||||
UnicodeToString: None = ...,
|
||||
lazydata: Incomplete | None = ...,
|
||||
) -> _T_co: ...
|
||||
|
||||
debugging: int
|
||||
debugging_attr: int
|
||||
LCID: int
|
||||
ERRORS_BAD_CONTEXT: Incomplete
|
||||
ALL_INVOKE_TYPES: Incomplete
|
||||
|
||||
def debug_print(*args) -> None: ...
|
||||
def debug_attr_print(*args) -> None: ...
|
||||
def MakeMethod(func, inst, cls): ...
|
||||
|
||||
PyIDispatchType = _win32typing.PyIDispatch
|
||||
PyIUnknownType = _win32typing.PyIUnknown
|
||||
|
||||
_GoodDispatchTypes: TypeAlias = tuple[type[str], type[IIDType]]
|
||||
|
||||
@overload
|
||||
def Dispatch(
|
||||
IDispatch: str | PyIDispatchType | _GoodDispatchTypes | PyIUnknownType,
|
||||
userName: str | None,
|
||||
createClass: _DispatchCreateClass[_T],
|
||||
typeinfo: _win32typing.PyITypeInfo | None = ...,
|
||||
UnicodeToString: None = ...,
|
||||
clsctx: int = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def Dispatch(
|
||||
IDispatch: str | PyIDispatchType | _GoodDispatchTypes | PyIUnknownType,
|
||||
userName: str | None = ...,
|
||||
createClass: None = ...,
|
||||
typeinfo: _win32typing.PyITypeInfo | None = ...,
|
||||
UnicodeToString: None = ...,
|
||||
clsctx: int = ...,
|
||||
) -> CDispatch: ...
|
||||
def MakeOleRepr(IDispatch, typeinfo, typecomp): ...
|
||||
def DumbDispatch(
|
||||
IDispatch,
|
||||
userName: Incomplete | None = ...,
|
||||
createClass: Incomplete | None = ...,
|
||||
UnicodeToString: Incomplete | None = ...,
|
||||
clsctx=...,
|
||||
): ...
|
||||
|
||||
# Necessary for mypy to not throw AssertionError with win32com.client
|
||||
class CDispatch:
|
||||
def __init__(
|
||||
self,
|
||||
IDispatch,
|
||||
olerepr,
|
||||
userName: Incomplete | None = ...,
|
||||
UnicodeToString: Incomplete | None = ...,
|
||||
UnicodeToString: None = ...,
|
||||
lazydata: Incomplete | None = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, *args): ...
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from win32com.client import dynamic
|
||||
|
||||
def EnsureDispatch(
|
||||
prog_id: str | dynamic.PyIDispatchType | dynamic._GoodDispatchTypes | dynamic.PyIUnknownType, bForDemand: int = ...
|
||||
) -> dynamic.CDispatch: ...
|
||||
@@ -19,4 +19,4 @@ class DispatcherOutputDebugString(DispatcherTrace): ...
|
||||
class DispatcherWin32dbg(DispatcherBase):
|
||||
def __init__(self, policyClass, ob) -> None: ...
|
||||
|
||||
DefaultDebugDispatcher: TypeAlias = DispatcherWin32trace
|
||||
DefaultDebugDispatcher: TypeAlias = DispatcherTrace
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from _typeshed import Incomplete
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from pythoncom import (
|
||||
DISPID_COLLECT as DISPID_COLLECT,
|
||||
@@ -20,13 +21,21 @@ regAddnPath: str
|
||||
|
||||
def CreateInstance(clsid, reqIID): ...
|
||||
|
||||
class BasicWrapPolicy:
|
||||
class BasicWrapPolicy(ABC):
|
||||
def __init__(self, object) -> None: ...
|
||||
def _InvokeEx_(self, dispid, lcid, wFlags, args, kwargs, serviceProvider) -> tuple[Incomplete]: ...
|
||||
@abstractmethod
|
||||
def _invokeex_(self, dispid, lcid, wFlags, args, kwargs, serviceProvider) -> tuple[Incomplete]: ...
|
||||
|
||||
class MappedWrapPolicy(BasicWrapPolicy):
|
||||
_dispid_to_func_: dict[int, str]
|
||||
def _invokeex_(self, dispid, lcid, wFlags, args, kwargs, serviceProvider) -> tuple[Incomplete]: ...
|
||||
|
||||
class MappedWrapPolicy(BasicWrapPolicy): ...
|
||||
class DesignatedWrapPolicy(MappedWrapPolicy): ...
|
||||
class EventHandlerPolicy(DesignatedWrapPolicy): ...
|
||||
class DynamicPolicy(BasicWrapPolicy): ...
|
||||
|
||||
class DynamicPolicy(BasicWrapPolicy):
|
||||
def _invokeex_(self, dispid, lcid, wFlags, args, kwargs, serviceProvider) -> tuple[Incomplete]: ...
|
||||
|
||||
DefaultPolicy = DesignatedWrapPolicy
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from _typeshed import Incomplete
|
||||
|
||||
from pythoncom import com_error as com_error
|
||||
from win32com.client import gencache as gencache
|
||||
|
||||
def RegisterInterfaces(typelibGUID, lcid, major, minor, interface_names: Incomplete | None = ...): ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user