Skip to content

ctypes nested array constructor doesn't work with sequences #6212

@alanhdu

Description

@alanhdu

Using Python 3.7 and mypy 0.660 on the following code:

import ctypes

Quaternion = ctypes.c_int * 4
Pair = Quaternion * 2

quat = Quaternion(1, 2, 3, 4)
p = Pair((1, 2, 3, 4), (2, 3, 4, 5))

returns

$ mypy ctypes_nested.py 
ctypes_nested.py:7: error: Array constructor argument 1 of type "Tuple[builtins.int, builtins.int, builtins.int, builtins.int]" is not convertible to the array element type "ctypes.Array[ctypes.c_int]"
ctypes_nested.py:7: error: Array constructor argument 2 of type "Tuple[builtins.int, builtins.int, builtins.int, builtins.int]" is not convertible to the array element type "ctypes.Array[ctypes.c_int]"

even though at runtime this constructor works just fine. Of course, changing the constructor to Pair(Quaternion(1, 2, 3, 4), Quaternion(2, 3, 4, 5)) works just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions