From 49e4d6d6eec46eff0329d070cb5e978c9dcf5ed3 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 10 Jul 2024 11:38:04 +0000 Subject: [PATCH] chore(internal): add helper function --- src/finch/_models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/finch/_models.py b/src/finch/_models.py index 5d95bb4b..eb7ce3bd 100644 --- a/src/finch/_models.py +++ b/src/finch/_models.py @@ -643,6 +643,14 @@ def validate_type(*, type_: type[_T], value: object) -> _T: return cast(_T, _validate_non_model_type(type_=type_, value=value)) +def set_pydantic_config(typ: Any, config: pydantic.ConfigDict) -> None: + """Add a pydantic config for the given type. + + Note: this is a no-op on Pydantic v1. + """ + setattr(typ, "__pydantic_config__", config) # noqa: B010 + + # our use of subclasssing here causes weirdness for type checkers, # so we just pretend that we don't subclass if TYPE_CHECKING: