Skip to content

Commit a73d998

Browse files
committed
rename env_vars argument to override_env_vars, update corresponding comments
1 parent ecb1a4b commit a73d998

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

temporalio/envconfig.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def load(
251251
disable_file: bool = False,
252252
disable_env: bool = False,
253253
config_file_strict: bool = False,
254-
env_vars: Optional[Mapping[str, str]] = None,
254+
override_env_vars: Optional[Mapping[str, str]] = None,
255255
) -> ClientConfigProfile:
256256
"""Load a single client profile from given sources, applying env
257257
overrides.
@@ -267,13 +267,14 @@ def load(
267267
disable_file: If true, file loading is disabled. This is only used
268268
when ``config_source`` is not present.
269269
disable_env: If true, environment variable loading and overriding
270-
is disabled. This takes precedence over the ``env_vars``
270+
is disabled. This takes precedence over the ``override_env_vars``
271271
parameter.
272272
config_file_strict: If true, will error on unrecognized keys.
273-
env_vars: The environment to use for loading and overrides. If not
274-
provided, environment variables are not used for overrides. To
275-
use the current process's environment, :py:attr:`os.environ` can be
276-
passed explicitly.
273+
override_env_vars: The environment to use for loading and overrides.
274+
If not provided, the current process's environment is used. To
275+
use a specific set of environment variables, provide them here.
276+
To disable environment variable loading, set ``disable_env`` to
277+
true.
277278
278279
Returns:
279280
The client configuration profile.
@@ -287,7 +288,7 @@ def load(
287288
disable_file=disable_file,
288289
disable_env=disable_env,
289290
config_file_strict=config_file_strict,
290-
env_vars=env_vars,
291+
env_vars=override_env_vars,
291292
)
292293
return ClientConfigProfile.from_dict(raw_profile)
293294

@@ -331,7 +332,7 @@ def load(
331332
config_source: Optional[DataSource] = None,
332333
disable_file: bool = False,
333334
config_file_strict: bool = False,
334-
env_vars: Optional[Mapping[str, str]] = None,
335+
override_env_vars: Optional[Mapping[str, str]] = None,
335336
) -> ClientConfig:
336337
"""Load all client profiles from given sources.
337338
@@ -348,11 +349,12 @@ def load(
348349
when ``config_source`` is not present.
349350
config_file_strict: If true, will TOML file parsing will error on
350351
unrecognized keys.
351-
env_vars: The environment variables to use for locating the default config
352-
file. If not provided, ``TEMPORAL_CONFIG_FILE`` is not checked
353-
and only the default path is used (e.g. ``~/.config/temporalio/temporal.toml``).
354-
To use the current process's environment, :py:attr:`os.environ` can be passed
355-
explicitly.
352+
override_env_vars: The environment variables to use for locating the
353+
default config file. If not provided, the current process's
354+
environment is used to check for ``TEMPORAL_CONFIG_FILE``. To
355+
use a specific set of environment variables, provide them here.
356+
To disable environment variable loading, set ``disable_file`` to
357+
true or pass an empty dictionary for this parameter.
356358
"""
357359
path, data = _source_to_path_and_data(config_source)
358360

@@ -361,7 +363,7 @@ def load(
361363
data=data,
362364
disable_file=disable_file,
363365
config_file_strict=config_file_strict,
364-
env_vars=env_vars,
366+
env_vars=override_env_vars,
365367
)
366368
return ClientConfig.from_dict(loaded_profiles)
367369

@@ -392,7 +394,10 @@ def load_client_connect_config(
392394
config_file_strict: If true, will error on unrecognized keys in the
393395
TOML file.
394396
override_env_vars: A dictionary of environment variables to use for
395-
loading and overrides.
397+
loading and overrides. If not provided, the current process's
398+
environment is used. To use a specific set of environment
399+
variables, provide them here. To disable environment variable
400+
loading, set ``disable_env`` to true.
396401
397402
Returns:
398403
TypedDict of keyword arguments for
@@ -408,6 +413,6 @@ def load_client_connect_config(
408413
disable_file=disable_file,
409414
disable_env=disable_env,
410415
config_file_strict=config_file_strict,
411-
env_vars=override_env_vars,
416+
override_env_vars=override_env_vars,
412417
)
413418
return prof.to_client_connect_config()

tests/test_envconfig.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_load_profile_from_data_env_overrides():
138138
"TEMPORAL_NAMESPACE": "env-namespace",
139139
}
140140
profile = ClientConfigProfile.load(
141-
config_source=TOML_CONFIG_BASE, profile="custom", env_vars=env
141+
config_source=TOML_CONFIG_BASE, profile="custom", override_env_vars=env
142142
)
143143
assert profile.address == "env-address"
144144
assert profile.namespace == "env-namespace"
@@ -156,7 +156,7 @@ def test_load_profile_env_overrides(base_config_file: Path):
156156
"TEMPORAL_TLS_SERVER_NAME": "env-server-name",
157157
}
158158
profile = ClientConfigProfile.load(
159-
config_source=base_config_file, profile="custom", env_vars=env
159+
config_source=base_config_file, profile="custom", override_env_vars=env
160160
)
161161
assert profile.address == "env-address"
162162
assert profile.namespace == "env-namespace"
@@ -181,7 +181,7 @@ def test_load_profile_grpc_meta_env_overrides(base_config_file: Path):
181181
"TEMPORAL_GRPC_META_ANOTHER_HEADER": "another-value",
182182
}
183183
profile = ClientConfigProfile.load(
184-
config_source=base_config_file, profile="custom", env_vars=env
184+
config_source=base_config_file, profile="custom", override_env_vars=env
185185
)
186186
assert profile.grpc_meta["custom-header"] == "env-value"
187187
assert profile.grpc_meta["another-header"] == "another-value"
@@ -197,7 +197,7 @@ def test_load_profile_disable_env(base_config_file: Path):
197197
"""Test that `disable_env` prevents environment variable overrides."""
198198
env = {"TEMPORAL_ADDRESS": "env-address"}
199199
profile = ClientConfigProfile.load(
200-
config_source=base_config_file, env_vars=env, disable_env=True
200+
config_source=base_config_file, override_env_vars=env, disable_env=True
201201
)
202202
assert profile.address == "default-address"
203203

@@ -209,7 +209,7 @@ def test_load_profile_disable_file(monkeypatch):
209209
"""Test that `disable_file` loads configuration only from environment."""
210210
monkeypatch.setattr("pathlib.Path.exists", lambda _: False)
211211
env = {"TEMPORAL_ADDRESS": "env-address"}
212-
profile = ClientConfigProfile.load(disable_file=True, env_vars=env)
212+
profile = ClientConfigProfile.load(disable_file=True, override_env_vars=env)
213213
assert profile.address == "env-address"
214214

215215
config = profile.to_client_connect_config()
@@ -263,7 +263,7 @@ def test_load_profiles_no_env_override(tmp_path: Path, monkeypatch):
263263
"TEMPORAL_CONFIG_FILE": str(config_file),
264264
"TEMPORAL_ADDRESS": "env-address", # This should be ignored
265265
}
266-
client_config = ClientConfig.load(env_vars=env)
266+
client_config = ClientConfig.load(override_env_vars=env)
267267
connect_config = client_config.profiles["default"].to_client_connect_config()
268268
assert connect_config.get("target_host") == "default-address"
269269

@@ -272,7 +272,7 @@ def test_load_profiles_no_config_file(monkeypatch):
272272
"""Test that load_profiles works when no config file is found."""
273273
monkeypatch.setattr("pathlib.Path.exists", lambda _: False)
274274
monkeypatch.setattr(os, "environ", {})
275-
client_config = ClientConfig.load(env_vars={})
275+
client_config = ClientConfig.load(override_env_vars={})
276276
assert not client_config.profiles
277277

278278

@@ -281,14 +281,14 @@ def test_load_profiles_discovery(tmp_path: Path, monkeypatch):
281281
config_file = tmp_path / "config.toml"
282282
config_file.write_text(TOML_CONFIG_BASE)
283283
env = {"TEMPORAL_CONFIG_FILE": str(config_file)}
284-
client_config = ClientConfig.load(env_vars=env)
284+
client_config = ClientConfig.load(override_env_vars=env)
285285
assert "default" in client_config.profiles
286286

287287

288288
def test_load_profiles_disable_file():
289289
"""Test load_profiles with file loading disabled."""
290290
# With no env vars, should be empty
291-
client_config = ClientConfig.load(disable_file=True, env_vars={})
291+
client_config = ClientConfig.load(disable_file=True, override_env_vars={})
292292
assert not client_config.profiles
293293

294294

0 commit comments

Comments
 (0)