-
Notifications
You must be signed in to change notification settings - Fork 2
Description
src/pysatl_core/sampling/unuran/bindings/_cffi_build.py, line 21:
from cffi import FFI # type: ignore[import-untyped]Problem
There are two distinct issues here that compound each other.
1. The suppression comment itself is now an error
Running mypy in strict mode (as configured in pyproject.toml) produces:
src/pysatl_core/sampling/unuran/bindings/_cffi_build.py:21:
error: Unused "type: ignore" comment [unused-ignore]
Under the current mypy version, importing cffi does not raise [import-untyped], so the
suppression comment is dead code — but the [unused-ignore] error it produces is a real mypy
error that breaks strict-mode checking.
2. cffi ships no type information at all
Checking the installed package:
py.typed present : False
.pyi stub files : []
cffi has neither a py.typed marker nor bundled .pyi stubs. Because mypy silently treats the
import as Any-typed rather than raising [import-untyped], the suppression goes undetected —
but the underlying lack of types is real.
Every object that flows through cffi is typed as Any:
| Object | Declared type | Runtime type |
|---|---|---|
ffi (FFI instance) |
Any |
cffi.api.FFI |
lib (compiled extension) |
Any |
_cffi_backend.Lib |
| CFFI callbacks | Any |
_cffi_backend.__CDataOwnGC |
unuran_distr, unuran_gen, unuran_par |
Any |
CFFI pointers |
All call sites in callbacks.py, dgt.py, initialization.py, and unuran_sampler.py annotate
these as Any precisely because cffi gives no types. This means:
- Wrong argument counts or types in
lib.unur_*()calls are invisible to the type checker. - Incorrect CFFI callback signatures (e.g. passing
"double(double)"where"double(int, ...)"is
expected) are not caught at definition time. - Returning a wrong type from a callback goes unnoticed.
Minimal reproduction
$ poetry run mypy src/pysatl_core/sampling/unuran/bindings/_cffi_build.py
src/pysatl_core/sampling/unuran/bindings/_cffi_build.py:21:
error: Unused "type: ignore" comment [unused-ignore]
Metadata
Metadata
Assignees
Labels
Type
Projects
Status