Hi John,
I’m skeptical that using cython.locals and hints would work
Is there a guide to working with the cython compiler sources somewhere? I might take a look at trying to add some alias support.
There's a little bit
https://github.com/cython/cython/wiki/HackerGuide but it's pretty
outdated and probably not too helpful to you.
Very rough outline about how you might do this: I can't promise it's all true though. After the "ControlFlowAnalysis" stage each entry with have a list of assignments (cf_assignments). (Although we might skip this for globals... I'm not completely sure... It'd be a problem here if we did). Essentially you'll be looking for an entry with a single assignment, where calling `analyse_as_type` gives you an answer. You probably want to do this in `NameNode.declare_from_annotation`.
A word of warning though: it's quite likely a big enough feature that we'd put it in Cython 3.2 so might not be usable hugely soon even if you got it working.
The other thing you could try is
ExprDict = cython.typedef(dict[str,Expr])
I'm not completely sure if that'll work, and it's a bit of a deviation from the pure "type annotation" syntax. But it's quick to test and find found.
David