MINOR: Suppress Pydantic Warnings (#20851)

This commit is contained in:
Mayur Singal 2025-04-16 16:44:14 +05:30 committed by GitHub
parent 04c327189b
commit 654529ab7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -106,7 +106,7 @@ class BaseModel(PydanticBaseModel):
exclude_defaults: bool = False, exclude_defaults: bool = False,
exclude_none: bool = True, exclude_none: bool = True,
round_trip: bool = False, round_trip: bool = False,
warnings: Union[bool, Literal["none", "warn", "error"]] = True, warnings: Union[bool, Literal["none", "warn", "error"]] = "none",
fallback: Optional[Callable[[Any], Any]] = None, fallback: Optional[Callable[[Any], Any]] = None,
serialize_as_any: bool = False, serialize_as_any: bool = False,
) -> str: ) -> str:
@ -150,12 +150,17 @@ class BaseModel(PydanticBaseModel):
self, self,
*, *,
mask_secrets: bool = False, mask_secrets: bool = False,
warnings: Union[bool, Literal["none", "warn", "error"]] = "none",
**kwargs, **kwargs,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
if mask_secrets: if mask_secrets:
context = kwargs.pop("context", None) or {} context = kwargs.pop("context", None) or {}
context["mask_secrets"] = True context["mask_secrets"] = True
kwargs["context"] = context kwargs["context"] = context
if "warnings" not in kwargs:
kwargs["warnings"] = warnings
return super().model_dump(**kwargs) return super().model_dump(**kwargs)