Skip to content

Simplify env var config lookups#1382

Merged
sirosen merged 1 commit intoglobus:mainfrom
sirosen:improve-env-var-loading
May 4, 2026
Merged

Simplify env var config lookups#1382
sirosen merged 1 commit intoglobus:mainfrom
sirosen:improve-env-var-loading

Conversation

@sirosen
Copy link
Copy Markdown
Member

@sirosen sirosen commented May 1, 2026

Our env var loading code has not aged well with the advent of type checking -- it is very dynamically typed, and attempting to annotate it precisely is overly complex. Even with type overloads, the resulting helper is not properly typed in all cases, and cannot extend to new callback types gracefully.

Simplify env var loading to follow some common patterns without using complex helpers.

No behaviors were intentionally changed, although a TODO note was added to an odd decision to convert "" to a default in one case.

Our env var loading code has not aged well with the advent of type
checking -- it is very dynamically typed, and attempting to annotate it
precisely is overly complex. Even with type overloads, the resulting
helper is not properly typed in all cases, and cannot extend to new
callback types gracefully.

Simplify env var loading to follow some common patterns without using
complex helpers.

No behaviors were intentionally changed, although a TODO note was added
to an odd decision to convert `""` to a default in one case.
@sirosen sirosen force-pushed the improve-env-var-loading branch from 7062fb3 to dcfa162 Compare May 1, 2026 21:52
@sirosen sirosen added the no-news-is-good-news This change does not require a news file label May 1, 2026
Copy link
Copy Markdown
Contributor

@m1yag1 m1yag1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one question about logging differences between the old and new code. This does not block approval.

if inputenv is None:
value = os.getenv(ENVNAME_VAR, "production")
else:
log.debug(f"on lookup, default setting: {varname}={value}")
Copy link
Copy Markdown
Contributor

@m1yag1 m1yag1 May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the old code, the logs explicitly flagged whether the value was "default" or "non-default". I wanted to point this out in case losing that context wasn't intentional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered it acceptable, since we know what the default values are anyway.

That conditional logging would have made each of these getters more complex (either they do it themselves or there's a shared logging helper), so absent a strong motivation to keep the old logging, I simplified it.

@sirosen sirosen merged commit 75777f1 into globus:main May 4, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-news-is-good-news This change does not require a news file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants