Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partial Fix: init=False in dataclass fields ignored
Why - Previously, setting `init=False` in std field and pydantic's Field had no effect, the field still appears as a parameter in the generated `__init__` What - Added `init` attribute to `FieldInfo` and `Field` - Corrected docstring for `init_var` - Added check for `init` in `make_pydantic_fields_compatible` - Added test to confirm `init=False` fields don't show up in the signature Notes - Unfortunately, can still use the `init=False` as parameters in init... I think this is because of pydantic allowing the "extra" params that aren't explicitly defined - Even setting `ConfigDict(extra='forbid')` doesn't help here. From some debugging, it doesn't look like the model schema understands the `init=False`. So more work needed to actually throw an error.
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 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