From 5fbe2d4f44add3258eff566f3ceeb7ae1990fa6a Mon Sep 17 00:00:00 2001 From: Jun Komoda <45822440+junkmd@users.noreply.github.com> Date: Mon, 4 Nov 2024 08:59:34 +0900 Subject: [PATCH] Move the module defining the `GUID` symbol under the `_post_coinit` subpackage. (#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. --- comtypes/__init__.py | 6 +++--- comtypes/_memberspec.py | 2 +- comtypes/{GUID.py => _post_coinit/guid.py} | 0 comtypes/_post_coinit/misc.py | 2 +- comtypes/_post_coinit/unknwn.py | 3 ++- 5 files changed, 7 insertions(+), 6 deletions(-) rename comtypes/{GUID.py => _post_coinit/guid.py} (100%) diff --git a/comtypes/__init__.py b/comtypes/__init__.py index 7ed3337b6..78b69d8ad 100644 --- a/comtypes/__init__.py +++ b/comtypes/__init__.py @@ -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 @@ -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 @@ -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 diff --git a/comtypes/_memberspec.py b/comtypes/_memberspec.py index 5d950cc80..bb7a795ed 100644 --- a/comtypes/_memberspec.py +++ b/comtypes/_memberspec.py @@ -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) diff --git a/comtypes/GUID.py b/comtypes/_post_coinit/guid.py similarity index 100% rename from comtypes/GUID.py rename to comtypes/_post_coinit/guid.py diff --git a/comtypes/_post_coinit/misc.py b/comtypes/_post_coinit/misc.py index 9f811cc62..7fa865b32 100644 --- a/comtypes/_post_coinit/misc.py +++ b/comtypes/_post_coinit/misc.py @@ -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): diff --git a/comtypes/_post_coinit/unknwn.py b/comtypes/_post_coinit/unknwn.py index 3b345489c..b3177699f 100644 --- a/comtypes/_post_coinit/unknwn.py +++ b/comtypes/_post_coinit/unknwn.py @@ -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__)