Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
- Loading branch information
1 parent
b4d2eac
commit 8f3ac4e
Showing
4 changed files
with
72 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import List | ||
|
||
from pydantic import RootModel | ||
|
||
|
||
class Pets1(RootModel[List[str]]): | ||
pass | ||
|
||
|
||
Pets2 = RootModel[List[str]] | ||
|
||
|
||
class Pets3(RootModel): | ||
root: List[str] | ||
|
||
|
||
pets1 = Pets1(['dog', 'cat']) | ||
pets2 = Pets2(['dog', 'cat']) | ||
pets3 = Pets3(['dog', 'cat']) | ||
|
||
|
||
class Pets4(RootModel[List[str]]): | ||
pets: List[str] |
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,25 @@ | ||
from typing import List | ||
|
||
from pydantic import RootModel | ||
|
||
|
||
class Pets1(RootModel[List[str]]): | ||
pass | ||
|
||
|
||
Pets2 = RootModel[List[str]] | ||
|
||
|
||
class Pets3(RootModel): | ||
# MYPY: error: Missing type parameters for generic type "RootModel" [type-arg] | ||
root: List[str] | ||
|
||
|
||
pets1 = Pets1(['dog', 'cat']) | ||
pets2 = Pets2(['dog', 'cat']) | ||
pets3 = Pets3(['dog', 'cat']) | ||
|
||
|
||
class Pets4(RootModel[List[str]]): | ||
pets: List[str] | ||
# MYPY: error: Only `root` is allowed as a field of a `RootModel` [pydantic-field] |
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