在UserUpdateRequest模型中,nickname和email应该为可选的,但实际为必填参数。在pydantic v1和tortoise-orm 0.19.3中是正常工作的 In the UserUpdateRequest model, nickname and email should be optional, but are actually required parameters. This is working fine in pydantic v1 and tortoise-orm 0.19.3 ...
But, with the nullablereporterfield of the sameEventmodel doesn't happen the same in its schema: tortoise-orm/tests/contrib/test_pydantic.py Lines 84 to 99 inc030c9c "pydantic__main__tests__testmodels__Reporter__leaf": { "additionalProperties":False, ...
Union type can also be used to create optional fields in Pydantic. The “Union” type allows you to specify a set of possible hint types for a field. For instance, the following script defines a model with an optional name field that can be either a string or None: ...
Optional fields are treated are marked as "required" in v2. Example code attached worked in v1.10.11. Example Code from pydantic import BaseModel from typing import Optional class Foo(BaseModel): bar: Optional[str] class TestPydantic: def test_foo(self): Foo() # passes with v1.10.11 bu...
from __future__ import annotations from pydantic import BaseModel from typing import Optional class Foo(BaseModel): foo: Optional[str] = None class Bar(Foo): bar: Optional[str] = None def has_str(self) -> bool: reveal_type(self.foo) reveal_type(self.bar) return self.foo is not None...
Personally I am inclined to agree that it might have resulted in less confusion to havex: Optional[X]in a pydantic model behave similarly to other types, and similar to how it would work in a dataclass (required unless a default (e.g.None) is explicitly specified). But in practice this...
from pydantic import BaseModel, ConfigDict, Field, computed_field from paperqa.docs import Docs @@ -36,6 +37,14 @@ class EnvironmentState(BaseModel): docs: Docs session: PQASession = Field(..., alias="answer") tool_history: list[list[str]] = Field( default_factory=list, description=...
Bug description # Optional method arguments or local scope variables are not properly inferred to be list[str] when in the if body. # example.py from typing import Optional from pydantic import BaseModel class Parents(BaseModel): name: s...
I’m the kind of guy who is known to rant about optionals, nulls, zeros, empty strings, empty arrays and empty objects and how all of them are distinct cases. Would really like if all of the cases here and in various linked issues could be easily expressed in a Pydantic model and ma...
from pydantic import Field from autotrain.trainers.common import AutoTrainParams class DreamBoothTrainingParams(AutoTrainParams): model: str = Field(None, title="Model name") revision: str = Field(None, title="Revision") tokenizer: str = Field(None, title="Tokenizer, if different from model...