66
77from __future__ import annotations
88
9- from dataclasses import dataclass , field
9+ from dataclasses import dataclass , field , replace
1010from pathlib import Path
1111from typing import Any , Dict , Literal , Mapping , Optional , Union , cast
1212
@@ -253,7 +253,7 @@ def to_client_connect_config(self) -> ClientConnectConfig:
253253
254254 @staticmethod
255255 def load (
256- profile : str = "default" ,
256+ profile : Optional [ str ] = None ,
257257 * ,
258258 config_source : Optional [DataSource ] = None ,
259259 disable_file : bool = False ,
@@ -268,7 +268,8 @@ def load(
268268 :py:meth:`to_client_connect_config` method on the returned profile.
269269
270270 Args:
271- profile: Profile to load from the config.
271+ profile: Profile to load from the config. If the profile is provided,
272+ the default profile is returned.
272273 config_source: If present, this is used as the configuration source
273274 instead of default file locations. This can be a path to the file
274275 or the string/byte contents of the file.
@@ -298,7 +299,13 @@ def load(
298299 config_file_strict = config_file_strict ,
299300 env_vars = override_env_vars ,
300301 )
301- return ClientConfigProfile .from_dict (raw_profile )
302+ prof = ClientConfigProfile .from_dict (raw_profile )
303+
304+ # If no address is present, default to localhost
305+ if prof .address is None :
306+ prof = replace (prof , address = "localhost:7233" )
307+
308+ return prof
302309
303310
304311@dataclass
@@ -377,7 +384,7 @@ def load(
377384
378385 @staticmethod
379386 def load_client_connect_config (
380- profile : str = "default" ,
387+ profile : Optional [ str ] = None ,
381388 * ,
382389 config_file : Optional [str ] = None ,
383390 disable_file : bool = False ,
@@ -392,7 +399,8 @@ def load_client_connect_config(
392399 process's environment for overrides unless disabled.
393400
394401 Args:
395- profile: The profile to load from the config. Defaults to "default".
402+ profile: Profile to load from the config. If the profile is provided,
403+ the default profile is returned.
396404 config_file: Path to a specific TOML config file. If not provided,
397405 default file locations are used. This is ignored if
398406 ``disable_file`` is true.
0 commit comments