-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert from BaseModel
to static jsonschema + TypedDict
#341
base: main
Are you sure you want to change the base?
Conversation
73a8dff
to
56b88ef
Compare
56b88ef
to
5f1d747
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! This is looking pretty good
3c618ec
to
fda7e64
Compare
59a86e9
to
fdf2837
Compare
fdf2837
to
3e827a2
Compare
315bf60
to
35645e1
Compare
DocumentType = Union[ | ||
Type[Datum], | ||
Type[DatumPage], | ||
Type[Event], | ||
Type[EventDescriptor], | ||
Type[EventPage], | ||
Type[Resource], | ||
Type[RunStart], | ||
Type[RunStop], | ||
Type[StreamDatum], | ||
Type[StreamResource], | ||
] | ||
|
||
ALL_DOCUMENTS: Tuple[DocumentType, ...] = ( | ||
Datum, | ||
DatumPage, | ||
Event, | ||
EventDescriptor, | ||
EventPage, | ||
Resource, | ||
RunStart, | ||
RunStop, | ||
StreamDatum, | ||
StreamResource, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file probably has to go back to how it was, at least for the presence of DocumentType
and ALL_DOCUMENTS
"anyOf": [ | ||
{ | ||
"type": "object" | ||
}, | ||
{ | ||
"type": "null" | ||
} | ||
], | ||
"default": null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is actually saying that downstream clients now need to cope with the presence of this key, and its value being nul...
data_keys: NotRequired[ | ||
Annotated[ | ||
Dict[str, DataKey], | ||
Field( | ||
description="This describes the data stored alongside it in this " | ||
"configuration object." | ||
), | ||
] | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...it used to be NotRequired[Dict]
...
class Configuration(BaseModel): | ||
model_config = ConfigDict(extra="forbid") | ||
data: Annotated[ | ||
Union[Dict[str, Any], None], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and now it's Union[Dict, None]
.
Is there any way to persuade pydantic to treat None
as NotRequired
in the JSON schema?
Closes #337