Skip to content

Commit

Permalink
Improve static typing for CoGetClassObject and GetClassObject. (#629
Browse files Browse the repository at this point in the history
)

* Update static typing for `CoGetClassObject`.

* Update static typing for `GetClassObject`.
  • Loading branch information
junkmd authored Sep 30, 2024
1 parent 8613f03 commit ca9b0f5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
20 changes: 14 additions & 6 deletions comtypes/_post_coinit/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,22 @@ def CoCreateInstance(
if TYPE_CHECKING:

@overload
def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
# type: (GUID, Optional[int], Optional[COSERVERINFO], None) -> hints.IClassFactory
pass
def CoGetClassObject(
clsid: GUID,
clsctx: Optional[int] = None,
pServerInfo: "Optional[COSERVERINFO]" = None,
interface: None = None,
) -> hints.IClassFactory:
...

@overload
def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
# type: (GUID, Optional[int], Optional[COSERVERINFO], Type[_T_IUnknown]) -> _T_IUnknown
pass
def CoGetClassObject(
clsid: GUID,
clsctx: Optional[int] = None,
pServerInfo: "Optional[COSERVERINFO]" = None,
interface: Type[_T_IUnknown] = hints.IClassFactory,
) -> _T_IUnknown:
...


def CoGetClassObject(clsid, clsctx=None, pServerInfo=None, interface=None):
Expand Down
20 changes: 14 additions & 6 deletions comtypes/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,22 @@ def _manage(
if TYPE_CHECKING:

@overload
def GetClassObject(progid, clsctx=None, pServerInfo=None):
# type: (_UnionT[str, CoClass, GUID], Optional[int], Optional[comtypes.COSERVERINFO]) -> hints.IClassFactory
pass
def GetClassObject(
progid: _UnionT[str, CoClass, GUID],
clsctx: Optional[int] = None,
pServerInfo: Optional[comtypes.COSERVERINFO] = None,
interface: None = None,
) -> hints.IClassFactory:
...

@overload
def GetClassObject(progid, clsctx=None, pServerInfo=None, interface=None):
# type: (_UnionT[str, CoClass, GUID], Optional[int], Optional[comtypes.COSERVERINFO], Optional[Type[_T_IUnknown]]) -> _T_IUnknown
pass
def GetClassObject(
progid: _UnionT[str, CoClass, GUID],
clsctx: Optional[int] = None,
pServerInfo: Optional[comtypes.COSERVERINFO] = None,
interface: Type[_T_IUnknown] = hints.IClassFactory,
) -> _T_IUnknown:
...


def GetClassObject(progid, clsctx=None, pServerInfo=None, interface=None):
Expand Down

0 comments on commit ca9b0f5

Please sign in to comment.