comtypes
comtypes copied to clipboard
modernize and add annotation to `_compointer_base.value`
This is the old property style.
https://github.com/enthought/comtypes/blob/4cbdb03b31583c6a974dd690d38f1abe69767dda/comtypes/_post_coinit/unknwn.py#L441-L445
This should be changed to the modern style with additional import sections.
from comtypes._memberspec import _ComMemberSpec, _DispMemberSpec
from comtypes._py_instance_method import instancemethod
+if TYPE_CHECKING:
+ from comtypes import hints # type: ignore
+
# redefine the .value property; return the object itself.
- def __get_value(self):
+ @property
+ def value(self) -> "hints.Self":
+ """Return self."""
return self
- value = property(__get_value, doc="""Return self.""")
-
_compointer_base, as its name implies, is the base class for POINTER(IUnknown) by metaclasses.
So, when returning self, it returns a POINTER(IUnknown) instance.
This is a 'GOOD FIRST ISSUE' because it requires only a few modifications to the code.
I will close this once to make it suitable for the drop_py2 plan.
With the drop_py2 plan complete, code modernization has become much easier. I thought it was time to reopen this issue.