[pythonic resources][rfc] Adjust EnvVar behavior to allow for direct usage #14488
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.
Summary
Small RFC in response to #14452. Keeps
EnvVar
as a direct subclass ofstr
but implements a custom override of__str__
to fetch the value from the environment in the case that the user attempts to use theEnvVar
anywhere.In the case that it's passed into a resource or config, the resolution will still happen in a lazy manner.
A potentially compelling alternative could be to error on
__str__
to explicitly prevent users from usingEnvVar
outside of resource/config contexts. Right now we're sort of in the worst of both worlds where a user can use anEnvVar
in inapproporiate places and they get an odd result (see user comment in the above issue). (See #14490 for an example of this)Test Plan
Small unit test, existing unit tests. Will expand suite if this is a direction we want to go.