diff --git a/comtypes/__init__.py b/comtypes/__init__.py index 33574462b..d86e7ad64 100644 --- a/comtypes/__init__.py +++ b/comtypes/__init__.py @@ -15,31 +15,30 @@ raise ImportError(msg) from e import atexit +import logging +import sys # HACK: Workaround for projects that depend on this package # There should be several projects around the world that depend on this package # and indirectly reference the symbols of `ctypes` from `comtypes`. # If we remove the wildcard import from `ctypes`, they might break. So it is # left in the following line. -from ctypes import * # noqa -from ctypes import HRESULT # noqa -from ctypes import _Pointer, _SimpleCData # noqa -from ctypes import c_int, c_ulong, OleDLL, WinDLL -from ctypes.wintypes import DWORD, LPVOID # noqa -import logging -import sys +from ctypes import * # noqa # type: ignore +from ctypes import HRESULT, OleDLL, WinDLL, _SimpleCData, c_int, c_ulong +from ctypes.wintypes import DWORD, LPVOID from typing import TYPE_CHECKING if TYPE_CHECKING: from ctypes import _CData # only in `typeshed`, private in runtime + from comtypes import hints as hints # noqa # type: ignore 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 +from comtypes.GUID import GUID _all_slice = slice(None, None, None) diff --git a/comtypes/_memberspec.py b/comtypes/_memberspec.py index 4132c6c2f..ece9109e1 100644 --- a/comtypes/_memberspec.py +++ b/comtypes/_memberspec.py @@ -1,12 +1,20 @@ import ctypes -from typing import Any, Literal, NamedTuple -from typing import Dict, List, Tuple, Type -from typing import Optional, Union as _UnionT -from typing import Callable, Iterator +from typing import ( + Any, + Callable, + Dict, + Iterator, + List, + Literal, + NamedTuple, + Optional, + Tuple, + Type, +) +from typing import Union as _UnionT -from comtypes import _CData import comtypes - +from comtypes import _CData _PositionalParamFlagType = Tuple[int, Optional[str]] _OptionalParamFlagType = Tuple[int, Optional[str], Any] diff --git a/comtypes/_meta.py b/comtypes/_meta.py index 7c1fa24ee..ce408c00b 100644 --- a/comtypes/_meta.py +++ b/comtypes/_meta.py @@ -1,5 +1,6 @@ # comtypes._meta helper module from ctypes import POINTER, c_void_p, cast + import comtypes ################################################################ diff --git a/comtypes/_safearray.py b/comtypes/_safearray.py index 68d4fd3b4..b34e3e12d 100644 --- a/comtypes/_safearray.py +++ b/comtypes/_safearray.py @@ -1,9 +1,9 @@ """SAFEARRAY api functions, data types, and constants.""" -from ctypes import c_uint, c_ushort, c_void_p, POINTER, Structure, WinDLL +from ctypes import POINTER, Structure, WinDLL, c_uint, c_ushort, c_void_p from ctypes.wintypes import DWORD, LONG, UINT, USHORT -from comtypes import HRESULT, GUID +from comtypes import GUID, HRESULT ################################################################ # if __debug__: