Cast assertions and generator tests #12

Merged
HEL merged 9 commits from feat/cast-assertions into main 2026-06-16 12:57:49 +00:00
Owner

This PR implements cast-assertion generation. For the moment, only the base type is checked.
It also adds RawStmt and RawExpr to store raw Python ast nodes that are not supported by the checker.
This PR also adds a preamble with some of the builtin Python functions
Finally, it adds a tester for the generator.

Here is a non-exhaustive list of things that still need to be implemented:

  • Stub generation: generate Python stubs or dummy classes for other type checkers
  • Constraints: when constraint types are implemented, generate assertions for the constraints
  • Generic unification: try and resolve generic type parameters given some values or parameters (e.g. to allow calling a bare generic function)
  • Implicit casts: allow some implicit casts / widening, especially for literal assignments (e.g. time: Second = 1.23)
  • Unsafe casts: add an unsafe alternative to cast which doesn't produce any runtime assertion, for example to avoid costly operations
This PR implements cast-assertion generation. For the moment, only the base type is checked. It also adds `RawStmt` and `RawExpr` to store raw Python ast nodes that are not supported by the checker. This PR also adds a preamble with some of the builtin Python functions Finally, it adds a tester for the generator. Here is a non-exhaustive list of things that still need to be implemented: - Stub generation: generate Python stubs or dummy classes for other type checkers - Constraints: when constraint types are implemented, generate assertions for the constraints - Generic unification: try and resolve generic type parameters given some values or parameters (e.g. to allow calling a bare generic function) - Implicit casts: allow some implicit casts / widening, especially for literal assignments (e.g. `time: Second = 1.23`) - Unsafe casts: add an unsafe alternative to `cast` which doesn't produce any runtime assertion, for example to avoid costly operations
HEL self-assigned this 2026-06-16 12:56:02 +00:00
HEL added 6 commits 2026-06-16 12:57:20 +00:00
HEL force-pushed feat/cast-assertions from 1aff8e574d to 2a8b7d559c 2026-06-16 12:57:20 +00:00 Compare
HEL merged commit 5ce3b4abed into main 2026-06-16 12:57:49 +00:00
HEL deleted branch feat/cast-assertions 2026-06-16 12:57:49 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: HEL/midas#12