-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid sharing extra template state between models (#2215)
* Avoid sharing extra template state between models * Update black version check in test skips to >= 24 --------- Co-authored-by: Koudai Aono <[email protected]>
- Loading branch information
Showing
13 changed files
with
313 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/data/expected/main/jsonschema/discriminator_literals_msgspec_keyword_only.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# generated by datamodel-codegen: | ||
# filename: discriminator_literals.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import ClassVar, Literal, Optional, Union | ||
|
||
from msgspec import Meta, Struct | ||
from typing_extensions import Annotated | ||
|
||
|
||
class Type1(Struct, kw_only=True, tag_field='type_', tag='a'): | ||
type_: ClassVar[Annotated[Literal['a'], Meta(title='Type ')]] = 'a' | ||
|
||
|
||
class Type2(Struct, kw_only=True, tag_field='type_', tag='b'): | ||
type_: ClassVar[Annotated[Literal['b'], Meta(title='Type ')]] = 'b' | ||
|
||
|
||
class UnrelatedType(Struct, kw_only=True): | ||
info: Optional[Annotated[str, Meta(title='A way to check for side effects')]] = ( | ||
'Unrelated type, not involved in the discriminated union' | ||
) | ||
|
||
|
||
class Response(Struct, kw_only=True): | ||
inner: Annotated[Union[Type1, Type2], Meta(title='Inner')] |
28 changes: 28 additions & 0 deletions
28
...ata/expected/main/jsonschema/discriminator_literals_msgspec_keyword_only_omit_defaults.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# generated by datamodel-codegen: | ||
# filename: discriminator_literals.json | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import ClassVar, Literal, Optional, Union | ||
|
||
from msgspec import Meta, Struct | ||
from typing_extensions import Annotated | ||
|
||
|
||
class Type1(Struct, omit_defaults=True, kw_only=True, tag_field='type_', tag='a'): | ||
type_: ClassVar[Annotated[Literal['a'], Meta(title='Type ')]] = 'a' | ||
|
||
|
||
class Type2(Struct, omit_defaults=True, kw_only=True, tag_field='type_', tag='b'): | ||
type_: ClassVar[Annotated[Literal['b'], Meta(title='Type ')]] = 'b' | ||
|
||
|
||
class UnrelatedType(Struct, omit_defaults=True, kw_only=True): | ||
info: Optional[Annotated[str, Meta(title='A way to check for side effects')]] = ( | ||
'Unrelated type, not involved in the discriminated union' | ||
) | ||
|
||
|
||
class Response(Struct, omit_defaults=True, kw_only=True): | ||
inner: Annotated[Union[Type1, Type2], Meta(title='Inner')] |
20 changes: 20 additions & 0 deletions
20
tests/data/expected/main/openapi/msgspec_keyword_only_omit_defaults.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# generated by datamodel-codegen: | ||
# filename: inheritance.yaml | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Optional | ||
|
||
from msgspec import Struct | ||
|
||
|
||
class Base(Struct, omit_defaults=True, kw_only=True): | ||
id: str | ||
createdAt: Optional[str] = None | ||
version: Optional[float] = 1 | ||
|
||
|
||
class Child(Base, omit_defaults=True, kw_only=True): | ||
title: str | ||
url: Optional[str] = 'https://example.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"#all#": { | ||
"base_class_kwargs": { | ||
"omit_defaults": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"#all#": { | ||
"base_class_kwargs": { | ||
"omit_defaults": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.