Skip to content

Commit 1cb8a97

Browse files
!refactor(config): Remove ENV lookup of all CLI flags
So far all CLI flags apart from positionals are loaded from corresponding environmental values. This feature is not really used and can be buggy, since fields with the same name can unintentionally collide between multiple configs. Thus, remove this feature entirely.
1 parent 66b3156 commit 1cb8a97

2 files changed

Lines changed: 0 additions & 16 deletions

File tree

src/gallia/cli/gallia.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def _create_parser_from_command(
3333
command: type[AsyncScript], config: Config, extra_defaults: defaults, model_counter: int = 0
3434
) -> tuple[type[PydanticBaseCommand], defaults, int]:
3535
config_attributes = command.CONFIG_TYPE.attributes_from_config(config)
36-
env_attributes = command.CONFIG_TYPE.attributes_from_env()
37-
config_attributes.update(env_attributes)
3836

3937
# it is necessary to create a submodel, because several commands can use the same config
4038
# (e.g. of their base class if no additional arguments are required)

src/gallia/command/config.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -445,17 +445,3 @@ def attributes_from_config(cls, config: Config, source: str = "config file") ->
445445
result[name] = (f"{source} ({info.config_section}:{name})", value)
446446

447447
return result
448-
449-
@classmethod
450-
def attributes_from_env(cls) -> dict[str, Any]:
451-
result = {}
452-
453-
if (original_infos := cls._original_field_infos) is not None:
454-
for name, info in original_infos.items():
455-
if isinstance(info, ConfigArgFieldInfo):
456-
config_attribute = f"GALLIA_{name.upper()}"
457-
458-
if (value := os.getenv(config_attribute)) is not None:
459-
result[name] = (f"environment variable ({config_attribute})", value)
460-
461-
return result

0 commit comments

Comments
 (0)