Skip to content

Complete Python API annotations and add ty and Ruff checks - #1472

Closed
matthiaskoenig wants to merge 1 commit into
sys-bio:developfrom
matthiaskoenig:issue-1422-python-typing
Closed

matthiaskoenig wants to merge 1 commit into
sys-bio:developfrom
matthiaskoenig:issue-1422-python-typing

Conversation

@matthiaskoenig

Copy link
Copy Markdown
Collaborator

Closes #1422.

The Python interface currently gives downstream type checkers little information about its SWIG API. Add a complete public stub layer covering 43 proxy classes, 884 function signatures, package exports, and the stochastic helpers, plus inline annotations for NamedArray. Editors and type checkers can now resolve constructor overloads, simulation results, settings, callbacks, model access, sensitivity results, and container methods.

The declarations follow the Python conversions in the bindings: NumPy arrays, Python lists/tuples, nullable solver factories, simulation file-output strings, and opaque SWIG handles are distinguished. Existing solver override differences have local, diagnostic-specific exceptions checked for staleness. No simulation, wrapper, or C++ logic changes.

Ship the stubs and py.typed through the CMake build/install trees, source distributions, and wheels. Add scoped ty and Ruff configuration, positive and negative downstream typing fixtures, a public API/re-export coverage check against freshly generated SWIG output, and CI for Python 3.10/NumPy 1.26 and Python 3.13/current NumPy. Development commands are in test/typing/README.md.

Validation:

  • ty, Ruff lint, and Ruff formatting pass on Python 3.10/NumPy 1.26.4 and Python 3.13/NumPy 2.5.5.
  • All 33 existing NamedArray runtime tests pass in both environments; its runtime AST is unchanged after stripping typing declarations.
  • Public stub and package-export coverage passes against SWIG 4.5.1 generated from the current sources.
  • CMake build/install, sdist, and wheel packaging checks pass with a placeholder native extension; an external consumer resolves the installed wheel's annotations with ty.

The native engine was not rebuilt for this annotation-only change.

@luciansmith

Copy link
Copy Markdown

Subsumed this into #1485

@luciansmith luciansmith closed this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type annotations for python API and type checking with ty

2 participants