diff --git a/comtypes/_post_coinit/unknwn.py b/comtypes/_post_coinit/unknwn.py index db004b95..ed644a15 100644 --- a/comtypes/_post_coinit/unknwn.py +++ b/comtypes/_post_coinit/unknwn.py @@ -22,7 +22,7 @@ def _shutdown( func=_CoUninitialize, _debug=logger.debug, -): +) -> None: # Sometimes, CoUninitialize, running at Python shutdown, # raises an exception. We suppress this when __debug__ is # False. @@ -135,7 +135,7 @@ def __new__(cls, name, bases, namespace): return self - def __setattr__(self, name, value): + def __setattr__(self, name: str, value: Any) -> None: if name == "_methods_": # XXX I'm no longer sure why the code generator generates # "_methods_ = []" in the interface definition, and later @@ -149,11 +149,11 @@ def __setattr__(self, name, value): self._make_specials() type.__setattr__(self, name, value) - def _make_specials(self): + def _make_specials(self) -> None: # This call installs methods that forward the Python protocols # to COM protocols. - def has_name(name): + def has_name(name: str) -> bool: # Determine whether a property or method named 'name' # exists if self._case_insensitive_: @@ -168,7 +168,7 @@ def has_name(name): if has_name("_NewEnum"): _meta_patch.iterator(self) - def _make_case_insensitive(self): + def _make_case_insensitive(self) -> None: # The __map_case__ dictionary maps lower case names to the # names in the original spelling to enable case insensitive # method and attribute access. @@ -201,7 +201,7 @@ def _make_dispmethods(self, methods: List["_DispMemberSpec"]) -> None: if self._case_insensitive_: self.__map_case__[name.lower()] = name - def __get_baseinterface_methodcount(self): + def __get_baseinterface_methodcount(self) -> int: "Return the number of com methods in the base interfaces" result = 0 for itf in self.mro()[1:-1]: @@ -268,7 +268,7 @@ class _compointer_base(c_void_p, metaclass=_compointer_meta): if TYPE_CHECKING: __com_interface__: ClassVar[Type["IUnknown"]] - def __del__(self, _debug=logger.debug): + def __del__(self, _debug=logger.debug) -> None: "Release the COM refcount we own." if self: # comtypes calls CoUninitialize() when the atexit handlers @@ -282,7 +282,7 @@ def __del__(self, _debug=logger.debug): _debug("Release %s", self) self.Release() # type: ignore - def __eq__(self, other): + def __eq__(self, other) -> bool: if not isinstance(other, _compointer_base): return False # get the value property of the c_void_p baseclass, this is the pointer value @@ -290,18 +290,18 @@ def __eq__(self, other): super(_compointer_base, self).value == super(_compointer_base, other).value ) - def __hash__(self): + def __hash__(self) -> int: """Return the hash value of the pointer.""" # hash the pointer values return hash(super(_compointer_base, self).value) # redefine the .value property; return the object itself. - def __get_value(self): + def __get_value(self) -> "hints.Self": return self value = property(__get_value, doc="""Return self.""") - def __repr__(self): + def __repr__(self) -> str: ptr = super(_compointer_base, self).value return f"<{self.__class__.__name__} ptr=0x{ptr or 0:x} at {id(self):x}>"