Skip to content

Commit

Permalink
Move the module defining the GUID symbol under the _post_coinit s…
Browse files Browse the repository at this point in the history
…ubpackage. (#653)

* `git mv comtypes/GUID.py comtypes/_post_coinit/guid.py`

* Modify the import sections
to reflect the definition changes.

* Avoid runtime errors caused by undefined references
by changing the type annotation to a string literal.
  • Loading branch information
junkmd authored Nov 3, 2024
1 parent e62a7e9 commit 5fbe2d4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions comtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
else:
_CData = _SimpleCData.__mro__[:-1][-1]

from comtypes.GUID import GUID
from comtypes import patcher # noqa
from comtypes._npsupport import interop as npsupport # noqa
from comtypes._tlib_version_checker import _check_version # noqa
Expand Down Expand Up @@ -73,8 +72,6 @@ class ReturnHRESULT(Exception):
# class IDLWarning(UserWarning):
# "Warn about questionable type information"

_GUID = GUID
IID = GUID
DWORD = c_ulong

wireHWND = c_ulong
Expand Down Expand Up @@ -182,7 +179,10 @@ def CoUninitialize():
################################################################

from comtypes._post_coinit.bstr import BSTR # noqa
from comtypes._post_coinit.guid import GUID

_GUID = GUID
IID = GUID

################################################################
# IPersist is a trivial interface, which allows to ask an object about
Expand Down
2 changes: 1 addition & 1 deletion comtypes/_memberspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def to_propputref_keys(self, m: _DispMemberSpec) -> Tuple[str, _DocType, int]:


class ComMemberGenerator(object):
def __init__(self, cls_name: str, vtbl_offset: int, iid: comtypes.GUID) -> None:
def __init__(self, cls_name: str, vtbl_offset: int, iid: "comtypes.GUID") -> None:
self._vtbl_offset = vtbl_offset
self._iid = iid
self._props = ComPropertyGenerator(cls_name)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion comtypes/_post_coinit/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
if TYPE_CHECKING:
from comtypes import hints as hints # noqa # type: ignore

from comtypes import GUID
from comtypes._idl_stuff import COMMETHOD # noqa
from comtypes import CLSCTX_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_REMOTE_SERVER
from comtypes import _ole32, oledll, DWORD
from comtypes._post_coinit.unknwn import IUnknown
from comtypes._post_coinit.guid import GUID


def _is_object(obj):
Expand Down
3 changes: 2 additions & 1 deletion comtypes/_post_coinit/unknwn.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from typing import Optional
from typing import List, Type

from comtypes import GUID, _ole32_nohresult, com_interface_registry
from comtypes import _ole32_nohresult, com_interface_registry
from comtypes._idl_stuff import STDMETHOD
from comtypes._memberspec import ComMemberGenerator, DispMemberGenerator
from comtypes._memberspec import _ComMemberSpec, _DispMemberSpec
from comtypes._post_coinit import _cominterface_meta_patcher as _meta_patch
from comtypes._post_coinit.guid import GUID
from comtypes._py_instance_method import instancemethod

logger = logging.getLogger(__name__)
Expand Down

0 comments on commit 5fbe2d4

Please sign in to comment.