Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to configure models through class kwargs (#2356)
* add support for class kwargs config * reformat tests * add changes file and docs * fix linting in 'inherit_config' * tweak docs Co-authored-by: Samuel Colvin <s@muelcolvin.com>
- Loading branch information
1 parent
5b14706
commit ce67660
Showing
5 changed files
with
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow configuring models through class kwargs |
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,11 @@ | ||
from pydantic import BaseModel, ValidationError, Extra | ||
|
||
|
||
class Model(BaseModel, extra=Extra.forbid): | ||
a: str | ||
|
||
|
||
try: | ||
Model(a='spam', b='oh no') | ||
except ValidationError as e: | ||
print(e) |
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