Skip to content

ctypes.c_bool(object) is not accepted #14823

Description

@patrickdepinguin

Python documentation says:
https://docs.python.org/3/library/ctypes.html#ctypes.c_bool

class ctypes.c_bool

    Represent the C bool datatype (more accurately, _Bool from C99). Its value can be True or False, 
    and the constructor accepts any object that has a truth value.

Following code is not accepted by mypy 1.18.2:

import ctypes
flag = ctypes.c_bool(0)

Output is:

/tmp/test.py:3: error: Argument 1 to "c_bool" has incompatible type "int"; expected "bool"  [arg-type]

Since this is valid Python code, I feel that mypy should accept it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions