Skip to content

Conversation

@junkmd
Copy link
Contributor

@junkmd junkmd commented Oct 8, 2024

Fixes #12736.

@github-actions

This comment has been minimized.

@Avasam
Copy link
Collaborator

Avasam commented Oct 9, 2024

As per the discussion in the the issue, it might be worth adding some tests (in stdlib/@tests/test_cases/check_ctypes.py ?) to show the expected return type as per common usage. If you are correct, then the return type isn't obvious. If not, then it'll show though isinstance/assert_type checks. It would be a good place to eternalize your reasoning and insight in a comment too !

Other than that, I think that the overload to allow None is welcome.

@github-actions

This comment has been minimized.

@junkmd
Copy link
Contributor Author

junkmd commented Oct 9, 2024

@Avasam

I read your comment and https://github.com/python/typeshed/blob/main/tests/REGRESSION.md.

I have committed what I thought should be added to stdlib/@tests/test_cases/check_ctypes.py, so could you check if my understanding is correct?

And it seems there's already stdlib/@tests/test_cases/multiprocessing/check_ctypes.py, and the name check_ctypes.py is duplicated, causing an error.
Could you also advise on how to resolve this?

@Avasam
Copy link
Collaborator

Avasam commented Oct 9, 2024

Could you also advise on how to resolve this?

Oh that's an easy fix. Just gotta make sure the filename is different. You could rename your test ctypes/check_pointer.py (imo the one in multiprocessing should be renamed, but let's avoid touching it in your PR).

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2024

Diff from mypy_primer, showing the effect of this PR on open source code:

comtypes (https://github.com/enthought/comtypes)
- comtypes/typeinfo.py:511: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/typeinfo.py:511: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:511: note: Possible overload variants:
+ comtypes/typeinfo.py:511: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:511: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/typeinfo.py:830: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
- comtypes/typeinfo.py:842: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
- comtypes/typeinfo.py:868: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
- comtypes/typeinfo.py:1036: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
+ comtypes/typeinfo.py:830: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:830: note: Possible overload variants:
+ comtypes/typeinfo.py:830: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:830: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/typeinfo.py:842: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:842: note: Possible overload variants:
+ comtypes/typeinfo.py:842: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:842: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/typeinfo.py:868: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:868: note: Possible overload variants:
+ comtypes/typeinfo.py:868: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:868: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/typeinfo.py:1036: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:1036: note: Possible overload variants:
+ comtypes/typeinfo.py:1036: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:1036: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/typeinfo.py:1102: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/typeinfo.py:1102: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/typeinfo.py:1102: note: Possible overload variants:
+ comtypes/typeinfo.py:1102: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/typeinfo.py:1102: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/safearray.py:70: error: Unused "type: ignore" comment  [unused-ignore]
- comtypes/errorinfo.py:13: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/errorinfo.py:13: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/errorinfo.py:13: note: Possible overload variants:
+ comtypes/errorinfo.py:13: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/errorinfo.py:13: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/errorinfo.py:24: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/errorinfo.py:24: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/errorinfo.py:24: note: Possible overload variants:
+ comtypes/errorinfo.py:24: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/errorinfo.py:24: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/errorinfo.py:42: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/errorinfo.py:42: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/errorinfo.py:42: note: Possible overload variants:
+ comtypes/errorinfo.py:42: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/errorinfo.py:42: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/unknwn.py:521: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
+ comtypes/_post_coinit/unknwn.py:521: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/unknwn.py:521: note: Possible overload variants:
+ comtypes/_post_coinit/unknwn.py:521: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/unknwn.py:521: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:51: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/_post_coinit/misc.py:51: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:51: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:51: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:51: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:80: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
- comtypes/_post_coinit/misc.py:81: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/_post_coinit/misc.py:80: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:80: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:80: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:80: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/_post_coinit/misc.py:81: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:81: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:81: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:81: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:188: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Never]"  [arg-type]
+ comtypes/_post_coinit/misc.py:188: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:188: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:188: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:188: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
- comtypes/_post_coinit/misc.py:242: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
- comtypes/_post_coinit/misc.py:245: error: Argument 1 to "POINTER" has incompatible type Module; expected "type[Any]"  [arg-type]
+ comtypes/_post_coinit/misc.py:242: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:242: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:242: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:242: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]
+ comtypes/_post_coinit/misc.py:245: error: No overload variant of "POINTER" matches argument type Module  [call-overload]
+ comtypes/_post_coinit/misc.py:245: note: Possible overload variants:
+ comtypes/_post_coinit/misc.py:245: note:     def POINTER(None, /) -> type[c_void_p]
+ comtypes/_post_coinit/misc.py:245: note:     def [_CT: _CData] POINTER(type[_CT], /) -> type[_Pointer[_CT]]

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primer output is just changed error messages.

@srittau srittau merged commit 1939ed1 into python:main Oct 10, 2024
63 checks passed
@junkmd
Copy link
Contributor Author

junkmd commented Oct 10, 2024

@Avasam

Oh that's an easy fix. Just gotta make sure the filename is different. You could rename your test ctypes/check_pointer.py

After following your advice and using git mv, the error no longer occurred.
Thank you.

(imo the one in multiprocessing should be renamed, but let's avoid touching it in your PR).

No objection.

@junkmd junkmd deleted the c_void_p branch October 10, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctypes POINTER invalid incompatible type with None

3 participants