This is needed to parse an arbitrary string as a type. This is especially important in context of TypeForm support (but is still needed in various other cases where we implicitly use old parser now, e.g. cast(), type alias targets etc).
Since we may make many calls to this function per file, overhead of using a Python call may be significant. We should probably consider adding a mypyc primitive for this that would use a capsule import from ast_serialize. It looks like PyO3 does support capsules, see https://docs.rs/pyo3/latest/pyo3/types/struct.PyCapsule.html
We can have a dedicated function in ast_serialize with a (much) simpler signature that also doesn't try to serialize imports etc.
@JukkaL what do you think?
This is needed to parse an arbitrary string as a type. This is especially important in context of
TypeFormsupport (but is still needed in various other cases where we implicitly use old parser now, e.g.cast(), type alias targets etc).Since we may make many calls to this function per file, overhead of using a Python call may be significant. We should probably consider adding a mypyc primitive for this that would use a capsule import from
ast_serialize. It looks like PyO3 does support capsules, see https://docs.rs/pyo3/latest/pyo3/types/struct.PyCapsule.htmlWe can have a dedicated function in
ast_serializewith a (much) simpler signature that also doesn't try to serialize imports etc.@JukkaL what do you think?