Gowee / json2pyi

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

`typing.Any` is not imported for `List[Any]` #3

Closed Gowee closed 1 year ago

Gowee commented 2 years ago

Currently, types from typing are only imported for those who are direct children of Maps. We need to check the inner of List as well.

Relevant code: https://github.com/Gowee/json2pyi/blob/1955a93db98e1059a39d86143a7cf65106409715/src/target/python_class.rs#L98

Sample JSON to reproduce:

{
    "page": {
        "id": "kctbh9vrtdwd",
        "name": "GitHub",
        "url": "https://www.githubstatus.com",
        "time_zone": "Etc/UTC",
        "updated_at": "2020-12-03T08:11:21.385Z"
    },
    "components": [
        {
            "id": "8l4ygp009s5s",
            "name": "Git Operations",
            "status": "operational",
            "created_at": "2017-01-31T20:05:05.370Z",
            "updated_at": "2020-10-29T22:51:43.831Z",
            "position": 1,
            "description": "Performance of git clones, pulls, pushes, and associated operations",
            "showcase": false,
            "start_date": null,
            "group_id": null,
            "page_id": "kctbh9vrtdwd",
            "group": false,
            "only_show_if_degraded": false
        }
    ],
    "incidents": [],
    "scheduled_maintenances": [],
    "status": {
        "indicator": "none",
        "description": "All Systems Operational"
    }
}