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 _ctypes.CFuncPtr constructor args #10154

Merged
merged 4 commits into from
May 7, 2023

Conversation

junkmd
Copy link
Contributor

@junkmd junkmd commented May 7, 2023

Quoting from #9251 (comment)

  • All of the arguments are positional-only and should be marked as such in the stub.

-> 35b1273

  • We're missing an overload for the case where no arguments are passed to the constructor.

-> e36b517

  • The overload with vtbl_index (not vtlb_index as the stub calls it) should exist only on Windows.

-> 9d7beb0, e86ea2e

I fixed them.


junkmd added 4 commits May 7, 2023 11:33
`vtlb_index` -> `vtbl_index`
for the case where no arguments are passed to the constructor
@JelleZijlstra JelleZijlstra self-assigned this May 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2023

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

comtypes (https://github.com/enthought/comtypes)
+ comtypes/_memberspec.py:357: note:     def __init__(self) -> _FuncPointer
- comtypes/_memberspec.py:357: note:     def __init__(self, address: int) -> _FuncPointer
+ comtypes/_memberspec.py:357: note:     def __init__(self, int, /) -> _FuncPointer
- comtypes/_memberspec.py:357: note:     def __init__(self, callable: Callable[..., Any]) -> _FuncPointer
+ comtypes/_memberspec.py:357: note:     def __init__(self, Callable[..., Any], /) -> _FuncPointer
- comtypes/_memberspec.py:357: note:     def __init__(self, func_spec: Tuple[Union[str, int], CDLL], paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ...) -> _FuncPointer
+ comtypes/_memberspec.py:357: note:     def __init__(self, Tuple[Union[str, int], CDLL], Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., /) -> _FuncPointer
- comtypes/_memberspec.py:357: note:     def __init__(self, vtlb_index: int, name: str, paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., iid: _Pointer[c_int] = ...) -> _FuncPointer
+ comtypes/_memberspec.py:357: note:     def __init__(self, int, str, Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., _Pointer[c_int] = ..., /) -> _FuncPointer
+ comtypes/_memberspec.py:358: note:     def __init__(self) -> _FuncPointer
- comtypes/_memberspec.py:358: note:     def __init__(self, address: int) -> _FuncPointer
+ comtypes/_memberspec.py:358: note:     def __init__(self, int, /) -> _FuncPointer
- comtypes/_memberspec.py:358: note:     def __init__(self, callable: Callable[..., Any]) -> _FuncPointer
+ comtypes/_memberspec.py:358: note:     def __init__(self, Callable[..., Any], /) -> _FuncPointer
- comtypes/_memberspec.py:358: note:     def __init__(self, func_spec: Tuple[Union[str, int], CDLL], paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ...) -> _FuncPointer
+ comtypes/_memberspec.py:358: note:     def __init__(self, Tuple[Union[str, int], CDLL], Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., /) -> _FuncPointer
- comtypes/_memberspec.py:358: note:     def __init__(self, vtlb_index: int, name: str, paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., iid: _Pointer[c_int] = ...) -> _FuncPointer
+ comtypes/_memberspec.py:358: note:     def __init__(self, int, str, Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., _Pointer[c_int] = ..., /) -> _FuncPointer

@JelleZijlstra JelleZijlstra merged commit 1d69fb3 into python:main May 7, 2023
@junkmd junkmd deleted the fix_CFuncPtr_ctor_args branch May 7, 2023 03:07
bkeryan added a commit to ni/nidaqmx-python that referenced this pull request Jun 5, 2023
typeshed was missing the no-arguments constructor for `_ctypes.CFuncPtr`
until very recently.
python/typeshed#10154

generated\nidaqmx\_library_interpreter.py:4414: error: All overload variants of "_FuncPointer" require at least one argument  [call-overload]
generated\nidaqmx\_library_interpreter.py:4414: note: Possible overload variants:
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, address: int) -> _FuncPointer
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, callable: Callable[..., Any]) -> _FuncPointer
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, func_spec: Tuple[Union[str, int], CDLL], paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ...) -> _FuncPointer
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, vtlb_index: int, name: str, paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., iid: _Pointer[c_int] = ...) -> _FuncPointer

Signed-off-by: Brad Keryan <brad.keryan@ni.com>
bkeryan added a commit to ni/nidaqmx-python that referenced this pull request Jun 6, 2023
typeshed was missing the no-arguments constructor for `_ctypes.CFuncPtr`
until very recently.
python/typeshed#10154

generated\nidaqmx\_library_interpreter.py:4414: error: All overload variants of "_FuncPointer" require at least one argument  [call-overload]
generated\nidaqmx\_library_interpreter.py:4414: note: Possible overload variants:
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, address: int) -> _FuncPointer
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, callable: Callable[..., Any]) -> _FuncPointer
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, func_spec: Tuple[Union[str, int], CDLL], paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ...) -> _FuncPointer
generated\nidaqmx\_library_interpreter.py:4414: note:     def _FuncPointer(self, vtlb_index: int, name: str, paramflags: Tuple[Union[Tuple[int], Tuple[int, str], Tuple[int, str, Any]], ...] = ..., iid: _Pointer[c_int] = ...) -> _FuncPointer

Signed-off-by: Brad Keryan <brad.keryan@ni.com>
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.

2 participants