1- from typing import Any , Dict , List , Type , TypeVar , Union
1+ from typing import Any , Type , TypeVar
22
33from pydantic import BaseModel
44
@@ -19,12 +19,12 @@ def __init__(self, registry: Registry) -> None:
1919 """
2020 self .registry = registry
2121
22- def build_components (self , config_dict : Dict , components_model_type : Type [BaseModelChild ]) -> BaseModelChild :
22+ def build_components (self , config_dict : dict , components_model_type : Type [BaseModelChild ]) -> BaseModelChild :
2323 """Builds the components from a config dictionary. All components specified in `components_model_type`
2424 are built from the config dictionary in a recursive manner.
2525
2626 Args:
27- config_dict (Dict ): Dictionary with the configuration of the components.
27+ config_dict (dict ): Dictionary with the configuration of the components.
2828 components_model_type (Type[BaseModelChild]): Base model type defining the components to be build.
2929
3030 Returns:
@@ -35,7 +35,7 @@ def build_components(self, config_dict: Dict, components_model_type: Type[BaseMo
3535 components = components_model_type (** component_dict )
3636 return components
3737
38- def _build_config (self , config_dict : Dict , component_names : List [str ]) -> Dict [str , Any ]:
38+ def _build_config (self , config_dict : dict , component_names : list [str ]) -> dict [str , Any ]:
3939 component_dict_filtered = {name : config_dict [name ] for name in component_names }
4040 components , _ = self ._build_component (
4141 current_component_config = component_dict_filtered ,
@@ -47,10 +47,10 @@ def _build_config(self, config_dict: Dict, component_names: List[str]) -> Dict[s
4747
4848 def _build_component (
4949 self ,
50- current_component_config : Union [ Dict , List , Any ] ,
51- component_config : Union [ Dict , List , Any ] ,
52- top_level_components : Dict [str , Any ],
53- traversal_path : List ,
50+ current_component_config : dict | list | Any ,
51+ component_config : dict | list | Any ,
52+ top_level_components : dict [str , Any ],
53+ traversal_path : list ,
5454 ) -> Any :
5555 # build sub components first via recursion
5656 if isinstance (current_component_config , dict ):
@@ -130,16 +130,16 @@ def _build_component(
130130 return current_component_config , top_level_components
131131
132132 @staticmethod
133- def _is_component_config (config_dict : Dict ) -> bool :
133+ def _is_component_config (config_dict : dict ) -> bool :
134134 # TODO instead of field checks, we should introduce an enum for the config type.
135135 return "component_key" in config_dict .keys ()
136136
137137 @staticmethod
138- def _is_reference_config (config_dict : Dict ) -> bool :
138+ def _is_reference_config (config_dict : dict ) -> bool :
139139 # TODO instead of field checks, we should introduce an enum for the config type.
140140 return {"instance_key" , "pass_type" } == config_dict .keys ()
141141
142- def _instantiate_component_config (self , component_key : str , variant_key : str , config_dict : Dict ) -> BaseModel :
142+ def _instantiate_component_config (self , component_key : str , variant_key : str , config_dict : dict ) -> BaseModel :
143143 component_config_type : Type [BaseModel ] = self .registry .get_config (component_key , variant_key )
144144 self ._assert_valid_config_keys (
145145 component_key = component_key ,
@@ -151,7 +151,7 @@ def _instantiate_component_config(self, component_key: str, variant_key: str, co
151151 return comp_config
152152
153153 def _assert_valid_config_keys (
154- self , component_key : str , variant_key : str , config_dict : Dict , component_config_type : Type [BaseModelChild ]
154+ self , component_key : str , variant_key : str , config_dict : dict , component_config_type : Type [BaseModelChild ]
155155 ) -> None :
156156 required_keys = []
157157 optional_keys = []
@@ -178,7 +178,7 @@ def _instantiate_component(self, component_key: str, variant_key: str, component
178178 return component
179179
180180 @staticmethod
181- def _base_model_to_dict (base_model : BaseModel ) -> Dict :
181+ def _base_model_to_dict (base_model : BaseModel ) -> dict :
182182 # converts top level structure of base_model into dictionary while maintaining substructure
183183 output = {}
184184 for name , _ in base_model .model_fields .items ():
0 commit comments