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
Allow star args in ctypes.Array constructor #6213
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ oa.value # E: ctypes.Array attribute "value" is only available with element typ | |
oa.raw # E: ctypes.Array attribute "raw" is only available with element type c_char, not "ctypes.c_int" | ||
[builtins fixtures/floatdict.pyi] | ||
|
||
[case testCtypesArrayConstructorStarargs-skip] | ||
[case testCtypesArrayConstructorStarargs] | ||
import ctypes | ||
|
||
intarr4 = ctypes.c_int * 4 | ||
|
@@ -167,4 +167,16 @@ reveal_type(intarr4(*int_values)) # E: Revealed type is 'ctypes.Array[ctypes.c_ | |
reveal_type(intarr4(*c_int_values)) # E: Revealed type is 'ctypes.Array[ctypes.c_int]' | ||
reveal_type(intarr6(1, ctypes.c_int(2), *int_values)) # E: Revealed type is 'ctypes.Array[ctypes.c_int]' | ||
reveal_type(intarr6(1, ctypes.c_int(2), *c_int_values)) # E: Revealed type is 'ctypes.Array[ctypes.c_int]' | ||
|
||
float_values = [1.0, 2.0, 3.0, 4.0] | ||
intarr4(*float_values) # E: Array constructor argument 1 of type "builtins.list[builtins.float*]" is not convertible to the array element type "Iterable[ctypes.c_int]" | ||
[builtins fixtures/floatdict.pyi] | ||
|
||
[case testCtypesArrayConstructorKwargs] | ||
import ctypes | ||
intarr4 = ctypes.c_int * 4 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to add a
I added a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this note caused some problems before. One option would be to add some very simple mock stubs to |
||
x = {"a": 1, "b": 2} | ||
intarr4(**x) # E: Too many arguments for "Array" | ||
|
||
[builtins fixtures/floatdict.pyi] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a test for this error message.