Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type annotations for idlflags and _dispimpl_. #817

Merged
merged 4 commits into from
Feb 23, 2025

Conversation

junkmd
Copy link
Collaborator

@junkmd junkmd commented Feb 23, 2025

The originator of this project left the following comment:

# Can dispid be at a different index? Should check code generator...

As seen in the refactored current codebase, dispid is only assigned at index 0 of idlflags.

  • ComMethodGenerator

    def _get_common_elms(self) -> Tuple[List[_IdlFlagType], str, str]:
    idlflags: List[_IdlFlagType] = []
    if self._isdual:
    idlflags.append(dispid(self._m.memid))
    idlflags.extend(self._m.idlflags)
    else: # We don't include the dispid for non-dispatch COM interfaces
    idlflags.extend(self._m.idlflags)
    if __debug__ and self._m.doc:
    idlflags.insert(1, helpstring(self._m.doc))
    type_name = self._to_type_name(self._m.returns)
    return (idlflags, type_name, self._m.name)

  • DispMethodGenerator

    def _get_common_elms(self) -> Tuple[List[_IdlFlagType], str, str]:
    idlflags: List[_IdlFlagType] = []
    idlflags.append(dispid(self._m.dispid))
    idlflags.extend(self._m.idlflags)
    if __debug__ and self._m.doc:
    idlflags.insert(1, helpstring(self._m.doc))
    type_name = self._to_type_name(self._m.returns)
    return (idlflags, type_name, self._m.name)

If there is a case where this is not true (i.e., where the newly added assert isinstance(dispid, comtypes.dispid) fails), it would be an undiscovered bug.

@junkmd junkmd added the typing related to Python static typing system label Feb 23, 2025
@junkmd junkmd added this to the 1.4.11 milestone Feb 23, 2025
junkmd added a commit to junkmd/pywinauto that referenced this pull request Feb 23, 2025
@junkmd junkmd merged commit 2e5d410 into enthought:main Feb 23, 2025
50 checks passed
@junkmd junkmd deleted the dispid_type_assertion branch February 23, 2025 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typing related to Python static typing system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant