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]
src/pysatl_core/sampling/unuran/bindings/_cffi_build.py, line 21:Problem
There are two distinct issues here that compound each other.
1. The suppression comment itself is now an error
Running
mypyin strict mode (as configured inpyproject.toml) produces:Under the current mypy version, importing
cffidoes not raise[import-untyped], so thesuppression comment is dead code — but the
[unused-ignore]error it produces is a real mypyerror that breaks strict-mode checking.
2. cffi ships no type information at all
Checking the installed package:
cffi has neither a
py.typedmarker nor bundled.pyistubs. Because mypy silently treats theimport 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:ffi(FFI instance)Anycffi.api.FFIlib(compiled extension)Any_cffi_backend.LibAny_cffi_backend.__CDataOwnGCunuran_distr,unuran_gen,unuran_parAnyAll call sites in
callbacks.py,dgt.py,initialization.py, andunuran_sampler.pyannotatethese as
Anyprecisely because cffi gives no types. This means:lib.unur_*()calls are invisible to the type checker."double(double)"where"double(int, ...)"isexpected) are not caught at definition time.
Minimal reproduction