1212from pydantic import ValidationError
1313
1414from .globals import ConfigScope , LOCAL_COPIA_FILE , GLOBAL_COPIA_FILE
15- from .models import Profile
15+ from .models import BaseProfile , resolve_profile
1616from .exceptions import (
1717 FoundProfileIsNotATableError ,
1818 ProfilesKeyIsNotATableError ,
@@ -71,7 +71,7 @@ def load_config(scope: ConfigScope) -> TOMLDocument:
7171 raise InvalidConfigError (f"{ scope } config file is not a valid TOML file: { TOMLErr } " )
7272
7373
74- def get_profile_from_config (profile_name : str , config : dict ) -> Profile :
74+ def get_profile_from_config (profile_name : str , config : dict ) -> BaseProfile :
7575 """try to get a valid profile from config
7676
7777 config must be a dict representation of the config file
@@ -89,7 +89,7 @@ def get_profile_from_config(profile_name: str, config: dict) -> Profile:
8989 InvalidProfileError: when the profile isn't valid
9090
9191 Returns:
92- Profile : a valid Profile object
92+ BaseProfile : a valid BaseProfile object
9393 """
9494 profiles = config .get ("profiles" )
9595 if profiles is None :
@@ -103,12 +103,12 @@ def get_profile_from_config(profile_name: str, config: dict) -> Profile:
103103 raise FoundProfileIsNotATableError (profile_name )
104104
105105 try :
106- return Profile ( ** profile_data )
106+ return resolve_profile ( profile_data )
107107 except ValidationError as Err :
108108 raise InvalidProfileError (Err )
109109
110110
111- def get_profile (profile_name : str , scope : ConfigScope ) -> Profile :
111+ def get_profile (profile_name : str , scope : ConfigScope ) -> BaseProfile :
112112 """try to get a valid profile from config based on scope
113113
114114 Args:
@@ -124,7 +124,7 @@ def get_profile(profile_name: str, scope: ConfigScope) -> Profile:
124124 InvalidProfileError: when the profile isn't valid
125125
126126 Returns:
127- Profile : a valid Profile object
127+ BaseProfile : a valid BaseProfile object
128128 """
129129 config = load_config (scope )
130130 return get_profile_from_config (profile_name , config )
0 commit comments