Skip to content

We need equivalent of parse_type_string() in native parser #21515

@ilevkivskyi

Description

@ilevkivskyi

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions