Gowee / json2pyi

Generate Python type definitions from a JSON sample (both Pydantic BaseModel and TypedDict are supported)
https://json2pyi.pages.dev
46 stars 1 forks source link

Order of generated models for PydanticBaseModel #6

Open s-rigaud opened 1 year ago

s-rigaud commented 1 year ago

I recently run into an issue with generated models from the website https://stackoverflow.com/questions/74346565/fastapi-typeerror-issubclass-arg-1-must-be-a-class-with-modular-imports/75789412#75789412

Importing the __annotations__ from future was leading to some problems. Just reordering the models starting from the subclass and removing the future import could be a nice feature to implement.

image

Gowee commented 1 year ago

We need to implement an alternative bottom-up iterator in topological order before adding such an option: https://github.com/Gowee/json2pyi/blob/9e23765795fd4f0e6f1cedf1a6596e896b6b27a8/src/target/python_class.rs#L83

s-rigaud commented 1 year ago

I would happily help you with that but I have no experience with Rust and just trying to read the code base without any knowledge of it gave me a headache 😅 I would consider helping you on this maybe in a few weeks, time to learn more abour Rust 😄