8000 Cannot typecheck ctypes NULL pointer instantiation · Issue #13930 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
Cannot typecheck ctypes NULL pointer instantiation #13930
Closed
@etanol

Description

@etanol

Bug Report

According to the ctypes documentation, the ctypes.POINTER factory function creates new pointer types. If those pointer types are called/instantiated without arguments, then a NULL pointer is created.

python/typeshed#8446 fixed some errors in the ctypes type definitions. But now, Mypy still fails to validate legal code creating NULL pointers.

To Reproduce

from ctypes import POINTER, c_char

charp = POINTER(c_char)
null = charp()
assert not null, "NULL is evaluating to True!"

Expected Behavior

The above snippet should successfully type check.

Actual Behavior

sample.py:4: error: Missing positional argument "arg" in call to "pointer"
    null = charp()
           ^
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.982
  • Mypy command-line flags: --pretty
  • Mypy configuration options from mypy.ini (and other config files): no customizations, no INI file created
  • Python version used: 3.10.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0