feat: make environment variables opt-in via option(env=...) - #7
Merged
Conversation
bhirsz
force-pushed
the
feat/opt-in-env
branch
from
August 28, 2026 12:23
d90d0cf to
afc9c88
Compare
bhirsz
force-pushed
the
feat/opt-in-env
branch
from
August 28, 2026 12:43
afc9c88 to
e9aafb4
Compare
Environment reading is now opt-in per option instead of an implicit, class-wide behaviour: * @option(env=True) reads a variable whose name is generated from the class env_var_template (default "{name}_{option}" upper-cased). * @option(env="NAME") sets an explicit variable name verbatim. * @option (default env=False) is never read from the environment. Adds the env_var_template class attribute so tools can customise the generated names. Migration (pre-1.0, no stability guarantees yet): the envvar= argument of @option and the auto_env_vars class attribute are removed; declare env= on each option that should read the environment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bhirsz
force-pushed
the
feat/opt-in-env
branch
from
August 28, 2026 12:46
e9aafb4 to
33b05f7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #6 (base branch
feat/cli-config-toggles).Makes reading from the environment opt-in per option instead of an implicit, class-wide behaviour.
@option(env=True)— reads a variable whose name is generated from the classenv_var_template(default"{name}_{option}", formatted with the tool name + attribute name and upper-cased, e.g.MYTOOL_LOG).@option(env="NAME")— sets an explicit variable name, used verbatim.@option(defaultenv=False) — never read from the environment.Adds the
env_var_templateclass attribute so tools can customise generated names.Breaking changes
envvar=argument of@optionis removed → useenv="NAME".auto_env_varsclass attribute is removed → addenv=Trueto each option that should read the environment.Validation
ruff/ruff format --check/mypy/pytestall green (168 tests); verifiedMYTOOL_CONSOLEandGREETER_WHOend-to-end against the demo and example.