Skip to content

Commit 6dfa711

Browse files
committed
refactor: Improve return type hints for ITypeComp.Bind.
Refines the return type hints for the `ITypeComp.Bind` method in `typeinfo.py` to use `typing.Literal` for the kind string, providing more precise type information and enhancing static analysis capabilities.
1 parent d055441 commit 6dfa711

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

comtypes/typeinfo.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
WCHAR,
3232
WORD,
3333
)
34-
from typing import TYPE_CHECKING, Any, Optional, TypeVar, overload
34+
from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, overload
3535
from typing import Union as _UnionT
3636

3737
from comtypes import BSTR, COMMETHOD, GUID, IID, STDMETHOD, IUnknown, _CData
@@ -430,7 +430,12 @@ class ITypeComp(IUnknown):
430430

431431
def Bind(
432432
self, name: str, flags: int = 0, lHashVal: int = 0
433-
) -> Optional[tuple[str, _UnionT["FUNCDESC", "VARDESC", "ITypeComp"]]]:
433+
) -> _UnionT[
434+
tuple[Literal["function"], "FUNCDESC"],
435+
tuple[Literal["variable"], "VARDESC"],
436+
tuple[Literal["type"], "ITypeComp"],
437+
None,
438+
]:
434439
"""Bind to a name"""
435440
bindptr = BINDPTR()
436441
desckind = DESCKIND()

0 commit comments

Comments
 (0)