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

Add LP_SAFEARRAY.from_param to hints.pyi. #687

Merged

Conversation

junkmd
Copy link
Collaborator

@junkmd junkmd commented Dec 7, 2024

While reviewing test_safearray, I noticed that the type checker raises an error because it infers the type of a variable assigned an instance generated by LP_SAFEARRAY.from_param as LP_SAFEARRAY | _CArgObject.

This behavior stems from the from_param classmethod in typeshed's ctypes module, which returns Self | _CArgObject as defined here.

At runtime, since POINTER(sa_type) overrides from_param, Self is consistently returned.

To suppress this false positive, I will define and override LP_SAFEARRAY.from_param in hints.pyi.

@junkmd junkmd added the typing related to Python static typing system label Dec 7, 2024
@junkmd junkmd added this to the 1.4.9 milestone Dec 7, 2024
junkmd added a commit to junkmd/pywinauto that referenced this pull request Dec 7, 2024
@junkmd junkmd merged commit 7604b8d into enthought:main Dec 7, 2024
49 checks passed
@junkmd junkmd deleted the improve_LP_SAFEARRAY_from_param_typing branch December 7, 2024 08:36
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