Skip to content

fix typeinfo.LoadRegTypeLib type annotation #380

@junkmd

Description

@junkmd

My priority has shifted to modifying other modules, so I hope someone else will finish this unfinished work.

Currently

def LoadRegTypeLib(guid, wMajorVerNum, wMinorVerNum, lcid=0):
# type: (str, int, int, int) -> ITypeLib
"Load a registered type library"
tlib = POINTER(ITypeLib)()
_oleaut32.LoadRegTypeLib(byref(GUID(guid)), wMajorVerNum, wMinorVerNum, lcid, byref(tlib))
return tlib # type: ignore

Suggested change

def LoadRegTypeLib(guid, wMajorVerNum, wMinorVerNum, lcid=0):
    # type: (_UnionT[str, GUID], int, int, int) -> ITypeLib
    """Load a registered type library"""
    ...

Ratiole

The constructor arg of GUID will be casted to text_type.

def __init__(self, name=None):
if name is not None:
_CLSIDFromString(text_type(name), byref(self))

And str(GUID("xxxxxxxx-...")) will return 'xxxxxxxx-...'.

def __unicode__(self):
p = c_wchar_p()
_StringFromCLSID(byref(self), byref(p))
result = p.value
_CoTaskMemFree(p)
return result
__str__ = __unicode__

Thus, there is no problem guid argument is either str or GUID.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions