You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a JSON schema field is declared as "type": "array" with no further details, the generated data model code fails typechecking:
src/_models/__init__.py:1990: error: Missing type parameters for generic type "List" [type-arg]
src/_models/__init__.py:1991: error: Missing type parameters for generic type "List" [type-arg]
classSystemRpcListDownloadedModelsReturns(RootModel[List]):
root: List
Expected behavior
Untyped arrays should be effectively typed as List[Any] rather than List
Version:
OS: Linux
Python version: 3.12
datamodel-code-generator version: 0.26.3
Additional context
--use-generic-container-types just shifted the error to complaining about Sequence instead.
--use-standard-collections crashed mypy outright, so I didn't investigate that any further.
The offending schema field not having any type information at all regarding the permitted elements is probably a bug in its own right, but not one that has anything to do with datamodel-code-generator.
The text was updated successfully, but these errors were encountered:
I've since tried the msgspec output format on this problem, and it also does the wrong thing:
SystemRpcListDownloadedModelsReturns=List
So presumably the problem is occurring earlier, when the JSON schema entry is converted into a Python type hint (a bare array should be mapping to List[Any] rather than List)
Describe the bug
When a JSON schema field is declared as
"type": "array"
with no further details, the generated data model code fails typechecking:To Reproduce
Example schema snippet:
Used commandline:
The generated model that fails typechecking:
Expected behavior
Untyped arrays should be effectively typed as
List[Any]
rather thanList
Version:
Additional context
--use-generic-container-types
just shifted the error to complaining aboutSequence
instead.--use-standard-collections
crashedmypy
outright, so I didn't investigate that any further.The offending schema field not having any type information at all regarding the permitted elements is probably a bug in its own right, but not one that has anything to do with datamodel-code-generator.
The text was updated successfully, but these errors were encountered: