Skip to content

Type stubs missing public get_experiment() and get_dynamic_config() methods on StatsigBasePy #36

@brianfeucht

Description

@brianfeucht

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions