Skip to content

Commit

Permalink
Format import blocks in _*.py. (enthought#795)
Browse files Browse the repository at this point in the history
* Format the import block in `__init__.py`.

* Remove unused imports from `__init__.py`.

* Remove unnecessary `# noqa` comments from `__init__.py`.

* Add a `# type: ignore` comment to `__init__.py`.

* Format the import block in `_memberspec.py`.

* Format the import block in `_meta.py`.

* Format the import block in `_safearray.py`.
  • Loading branch information
junkmd authored Feb 4, 2025
1 parent 51c930f commit ace0062
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
15 changes: 7 additions & 8 deletions comtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 14 additions & 6 deletions comtypes/_memberspec.py
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
1 change: 1 addition & 0 deletions comtypes/_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# comtypes._meta helper module
from ctypes import POINTER, c_void_p, cast

import comtypes

################################################################
Expand Down
4 changes: 2 additions & 2 deletions comtypes/_safearray.py
Original file line number Diff line number Diff line change
@@ -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__:
Expand Down

0 comments on commit ace0062

Please sign in to comment.