@@ -23,8 +23,6 @@ class ConfigurationValueError(ConfigurationException, ValueError):
2323class ContainerException (DltException ):
2424 """base exception for all exceptions related to injectable container"""
2525
26- pass
27-
2826
2927class ConfigProviderException (ConfigurationException ):
3028 def __init__ (self , provider_name : str , * args : Any ) -> None :
@@ -35,8 +33,8 @@ def __init__(self, provider_name: str, *args: Any) -> None:
3533class ConfigurationWrongTypeException (ConfigurationException ):
3634 def __init__ (self , _typ : type ) -> None :
3735 super ().__init__ (
38- f"Invalid configuration instance type { _typ } . Configuration instances must derive from "
39- " BaseConfiguration and must be decorated with @configspec."
36+ f"Invalid configuration instance type ` { _typ } ` . Configuration instances must derive"
37+ " from BaseConfiguration and must be decorated with @configspec."
4038 )
4139
4240
@@ -50,14 +48,13 @@ def __init__(self, spec_name: str, traces: Mapping[str, Sequence[LookupTrace]])
5048 super ().__init__ (spec_name )
5149
5250 def __str__ (self ) -> str :
53- msg = (
54- f"Following fields are missing: { str (self .fields )} in configuration with spec"
55- f" { self .spec_name } \n "
56- )
51+ msg = f"Missing fields in configuration: { str (self .fields )} { self .spec_name } \n "
5752 for f , field_traces in self .traces .items ():
58- msg += f'\t for field "{ f } " config providers and keys were tried in following order:\n '
53+ msg += (
54+ f"\t for field `{ f } ` the following (config providers, keys) were tried in order:\n "
55+ )
5956 for tr in field_traces :
60- msg += f"\t \t In { tr .provider } key { tr .key } was not found. \n "
57+ msg += f"\t \t ( { tr .provider } , { tr .key } ) \n "
6158
6259 from dlt .common .configuration .container import Container
6360 from dlt .common .configuration .specs import PluggableRunContext
@@ -68,14 +65,12 @@ def __str__(self) -> str:
6865 for provider in providers .providers :
6966 if provider .locations :
7067 locations = "\n " .join ([f"\t - { os .path .abspath (loc )} " for loc in provider .locations ])
71- msg += (
72- f"Provider { provider .name } used following locations to load"
73- f" values:\n { locations } \n "
74- )
68+ msg += f"Provider `{ provider .name } ` loaded values from locations:\n { locations } \n "
69+
7570 if provider .is_empty :
7671 msg += (
77- f"WARNING: provider { provider .name } is empty. Locations (ie. files) may not "
78- " exist or may be empty.\n "
72+ f"WARNING: provider ` { provider .name } ` is empty. Locations (i.e., files) are "
73+ " missing or empty.\n "
7974 )
8075
8176 # check if entry point is run with path. this is common problem so warn the user
@@ -101,10 +96,7 @@ def __str__(self) -> str:
10196 " but run your script from some other folder, secrets/configs will not be"
10297 " found\n "
10398 )
104- msg += (
105- "Please refer to https://dlthub.com/docs/general-usage/credentials/ for more"
106- " information\n "
107- )
99+ msg += "Learn more: https://dlthub.com/docs/general-usage/credentials/\n "
108100 return msg
109101
110102 def attrs (self ) -> Dict [str , Any ]:
@@ -127,9 +119,9 @@ def __init__(self, spec_name: str, field_names: Sequence[str]) -> None:
127119 f">>> { name } : Any" for name in field_names
128120 )
129121 msg = (
130- f"The config spec { spec_name } has dynamic type resolvers for fields: { field_names } but "
131- " these fields are not defined in the spec.\n When using @resolve_type() decorator, Add "
132- f" the fields with 'Any' or another common type hint, example:\n \n { example } "
122+ f"The config spec ` { spec_name } ` has dynamic type resolvers for fields: ` { field_names } ` "
123+ " but these fields are not defined in the spec.\n When using @resolve_type() decorator,"
124+ f" Add the fields with 'Any' or another common type hint, example:\n \n { example } "
133125 )
134126 super ().__init__ (msg )
135127
@@ -139,7 +131,8 @@ class FinalConfigFieldException(ConfigurationException):
139131
140132 def __init__ (self , spec_name : str , field : str ) -> None :
141133 super ().__init__ (
142- f"Field { field } in spec { spec_name } is final but is being changed by a config provider"
134+ f"Field `{ field } ` in spec `{ spec_name } ` is final but is being changed by a config"
135+ " provider"
143136 )
144137
145138
@@ -151,7 +144,7 @@ def __init__(self, field_name: str, field_value: Any, hint: type) -> None:
151144 self .field_value = field_value
152145 self .hint = hint
153146 super ().__init__ (
154- "Configured value for field %s cannot be coerced into type %s" % ( field_name , str (hint ))
147+ f "Configured value for field ` { field_name } ` cannot be coerced into type ` { str (hint )} `"
155148 )
156149
157150
@@ -169,7 +162,7 @@ class ConfigFileNotFoundException(ConfigurationException):
169162 """thrown when configuration file cannot be found in config folder"""
170163
171164 def __init__ (self , path : str ) -> None :
172- super ().__init__ (f"Missing config file in { path } " )
165+ super ().__init__ (f"Missing config file in ` { path } ` " )
173166
174167
175168class ConfigFieldMissingTypeHintException (ConfigurationException ):
@@ -179,7 +172,7 @@ def __init__(self, field_name: str, spec: Type[Any]) -> None:
179172 self .field_name = field_name
180173 self .typ_ = spec
181174 super ().__init__ (
182- f"Field { field_name } on configspec { spec } does not provide required type hint"
175+ f"Field ` { field_name } ` on configspec ` { spec } ` does not provide required type hint"
183176 )
184177
185178
@@ -190,7 +183,7 @@ def __init__(self, field_name: str, spec: Type[Any], typ_: Type[Any]) -> None:
190183 self .field_name = field_name
191184 self .typ_ = spec
192185 super ().__init__ (
193- f"Field { field_name } on configspec { spec } has hint with unsupported type { typ_ } "
186+ f"Field ` { field_name } ` on configspec ` { spec } ` has hint with unsupported type ` { typ_ } ` "
194187 )
195188
196189
@@ -199,8 +192,8 @@ def __init__(self, provider_name: str, key: str) -> None:
199192 self .provider_name = provider_name
200193 self .key = key
201194 super ().__init__ (
202- f"Provider { provider_name } cannot hold secret values but key { key } with secret value is "
203- " present"
195+ f"Provider ` { provider_name } ` cannot hold secret values but key ` { key } ` with secret"
196+ " value is present"
204197 )
205198
206199
@@ -218,10 +211,9 @@ def __init__(
218211 self .inner_exception = inner_exception
219212 inner_msg = f" { self .inner_exception } " if inner_exception is not ValueError else ""
220213 super ().__init__ (
221- f"{ spec .__name__ } cannot parse the configuration value provided. The value is of type"
222- f" { native_value_type .__name__ } and comes from the"
223- " {embedded_sections} section(s). Value may be a secret and is not shown. "
224- f"Details: { inner_msg } "
214+ f"`{ spec .__name__ } ` cannot parse the configuration value provided. The value is of type"
215+ f" `{ native_value_type .__name__ } ` and comes from the sections `{ embedded_sections } `"
216+ f" Value may be a secret and is not shown. Details: { inner_msg } "
225217 )
226218
227219
@@ -231,20 +223,20 @@ def __init__(self, spec: Type[Any], existing_config: Any, expected_config: Any)
231223 self .existing_config = existing_config
232224 self .expected_config = expected_config
233225 super ().__init__ (
234- f"When restoring context { spec .__name__ } , instance { expected_config } was expected,"
235- f" instead instance { existing_config } was found."
226+ f"When restoring context ` { spec .__name__ } ` , instance ` { expected_config } ` was expected,"
227+ f" instead instance ` { existing_config } ` was found."
236228 )
237229
238230
239231class ContextDefaultCannotBeCreated (ContainerException , KeyError ):
240232 def __init__ (self , spec : Type [Any ]) -> None :
241233 self .spec = spec
242- super ().__init__ (f"Container cannot create the default value of context { spec .__name__ } ." )
234+ super ().__init__ (f"Container cannot create the default value of context ` { spec .__name__ } ` ." )
243235
244236
245237class DuplicateConfigProviderException (ConfigProviderException ):
246238 def __init__ (self , provider_name : str ) -> None :
247239 super ().__init__ (
248240 provider_name ,
249- f"Provider with name { provider_name } already present in ConfigProvidersContext" ,
241+ f"Provider with name ` { provider_name } ` already present in ` ConfigProvidersContext` " ,
250242 )
0 commit comments