Fix read_env recursive bug#370
Merged
sloria merged 6 commits intosloria:mainfrom Nov 20, 2024
Merged
Conversation
sloria
reviewed
Nov 20, 2024
Owner
sloria
left a comment
There was a problem hiding this comment.
Good catch! Just a few nits. I'll push up some test improvements shortly
| False as a second positional argument. | ||
| """ | ||
|
|
||
| env_path = "" |
Owner
There was a problem hiding this comment.
This results in an empty string being returned if a .env file isn't found. Not sure if this is the most intuitive; perhaps None should be returned?
Contributor
Author
There was a problem hiding this comment.
None works as well but my thought was to mimic the same behavior as find_dotenv(). None and an empty string works the same way for conditional checks, but I think None is more representative indeed.
| def test_read_env_return_path_with_dotenv_on_working_dir(self, env): | ||
| working_dir = pathlib.Path(os.getcwd()) | ||
| dotenv_path = working_dir / ".env" | ||
| open(dotenv_path, "x") # create .env on working dir |
Owner
There was a problem hiding this comment.
This will result in a failure if the assertion fails and the test is re-run. I'll push up a fix for this shortly
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.
The feature added by #364 introduced a behavior that
read_env()would always recurse the tree directory even when it has already found a .env file. Sorry about that.If you would have a .env file on your current working directory this file would be chosen instead another .env more deep on the tree where
read_env()was called.Bug fixed and I added tests to caught this behavior on future releases.