Problem
In statsig-python-core 0.16.x, the public API methods get_experiment()
and get_dynamic_config() work at runtime but are not included in the
generated type stubs (.pyi file), causing mypy errors despite the code
being correct.
Symptoms
# This works at runtime but mypy reports:
# error: "StatsigBasePy" has no attribute "get_experiment"
result = client.get_experiment(user, "experiment_name")
Root Cause
The type stubs generated by pyo3_stub_gen are incomplete and don't
include get_experiment and get_dynamic_config in the StatsigBasePy
class definition, even though these methods are available in the PyO3
compiled code.
Workaround
Currently requires # type: ignore[attr-defined] suppressions in code
that uses these public methods.
Expected Behavior
Type stubs should include all public methods, or these methods should be
explicitly exported in __all__.
The issue is fundamentally that the PyO3 stub generation isn't capturing all the public methods from the compiled extension.
Problem
In statsig-python-core 0.16.x, the public API methods
get_experiment()and
get_dynamic_config()work at runtime but are not included in thegenerated type stubs (
.pyifile), causing mypy errors despite the codebeing correct.
Symptoms
Root Cause
The type stubs generated by
pyo3_stub_genare incomplete and don'tinclude
get_experimentandget_dynamic_configin theStatsigBasePyclass definition, even though these methods are available in the PyO3
compiled code.
Workaround
Currently requires
# type: ignore[attr-defined]suppressions in codethat uses these public methods.
Expected Behavior
Type stubs should include all public methods, or these methods should be
explicitly exported in
__all__.The issue is fundamentally that the PyO3 stub generation isn't capturing all the public methods from the compiled extension.