1515
1616from abc import ABC , abstractmethod
1717from pydantic import BaseModel , Field
18- from typing import Optional , List , Dict , Literal , TypedDict
18+ from typing import Optional , List , Dict , Annotated , Union , Literal
1919from dotenv import dotenv_values
2020
2121class UtcpVariableNotFound (Exception ):
@@ -51,7 +51,7 @@ class UtcpVariablesConfig(BaseModel, ABC):
5151 Attributes:
5252 type: Type identifier for the variable loader.
5353 """
54- type : Literal [ "dotenv" ] = "dotenv"
54+ type : str
5555
5656 @abstractmethod
5757 def get (self , key : str ) -> Optional [str ]:
@@ -81,6 +81,7 @@ class UtcpDotEnv(UtcpVariablesConfig):
8181 api_key = loader.get("API_KEY")
8282 ```
8383 """
84+ type : Literal ["dotenv" ] = "dotenv"
8485 env_file_path : str
8586
8687 def get (self , key : str ) -> Optional [str ]:
@@ -94,6 +95,13 @@ def get(self, key: str) -> Optional[str]:
9495 """
9596 return dotenv_values (self .env_file_path ).get (key )
9697
98+ UtcpVariablesConfigUnion = Annotated [
99+ Union [
100+ UtcpDotEnv
101+ ],
102+ Field (discriminator = "type" )
103+ ]
104+
97105class UtcpClientConfig (BaseModel ):
98106 """Configuration model for UTCP client setup.
99107
@@ -128,4 +136,4 @@ class UtcpClientConfig(BaseModel):
128136 """
129137 variables : Optional [Dict [str , str ]] = Field (default_factory = dict )
130138 providers_file_path : Optional [str ] = None
131- load_variables_from : Optional [List [UtcpVariablesConfig ]] = None
139+ load_variables_from : Optional [List [UtcpVariablesConfigUnion ]] = None
0 commit comments