Skip to content

fix: raise the documented TypeError for wrong-type design and local_solver - #250

Merged
schroedk merged 1 commit into
mainfrom
fix/248-documented-exception-types
Aug 6, 2026
Merged

fix: raise the documented TypeError for wrong-type design and local_solver#250
schroedk merged 1 commit into
mainfrom
fix/248-documented-exception-types

Conversation

@schroedk

@schroedk schroedk commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #248.

solve / solve_batch / Solver raised ValueError for a design that is neither a 2-D uint32 array nor a list of Effect, and AdditiveSchwarz accepted any object as local_solver, deferring the TypeError to solve time. Both now raise the TypeError the stub already documents, and local_solver is validated at construction.

Typing the field Option<Py<PyLocalSolverConfig>> moves the check into PyO3's generated argument extraction, which retires the manual downcast in extract_preconditioner_config. _within.pyi needed no change — it was already correct on both counts.

LocalSolverConfig is not subclassable, so the accepted set is unchanged: no input that previously succeeded now fails. The four new tests were verified to fail against the pre-fix binary (ValueError for design, DID NOT RAISE for the constructor).

…olver

The .pyi documents TypeError for a wrong-type argument, but two paths
disagreed. extract_design mapped a failed Effect-list extraction through
value_err, so solve/solve_batch/Solver raised ValueError for a design
that is neither a 2-D uint32 array nor a list of Effect. And
AdditiveSchwarz typed local_solver as Option<Py<PyAny>>, accepting any
object at construction and deferring the TypeError to the downcast
inside extract_preconditioner_config at solve time.

Typing the field Option<Py<PyLocalSolverConfig>> makes PyO3 generate the
check at construction, which retires the manual downcast branch.
LocalSolverConfig is not subclassable, so the accepted set is unchanged:
no input that previously succeeded now fails, only already-failing paths
change how they fail.
@schroedk
schroedk merged commit 82785a3 into main Aug 6, 2026
5 checks passed
@schroedk
schroedk deleted the fix/248-documented-exception-types branch August 6, 2026 08:59
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.

fix: align _within.pyi exception types and constructor validation with runtime behavior

1 participant