Repository navigation
Conversation
…v file The config file is Python, so python-dotenv warned "could not parse statement" about any line that is not a plain assignment, such as an import on its first line. Since #2811 the Docker image finds its mounted config again, so every container logged this warning on startup. Now the file is parsed with ast, without running it, and only a top-level string literal counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
Documentation build overview
4 files changed± changelog.html± genindex.html± _autosummary/flexmeasures.utils.config_utils.html± api/v3_0.html |
This branch has not been deployed
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.
Description
Since v1.1.0, every container of the Docker image logs
WARNING: python-dotenv could not parse statement starting at line 1on startup.get_flexmeasures_env()looked upFLEXMEASURES_ENVinflexmeasures.cfgwithdotenv_values(). That file is Python, so python-dotenv warns about any line that is not a plainKEY = valueassignment, such asfrom datetime import timedeltaon line 1. Spaces around=are fine for dotenv; imports and other statements are not./app/instance, so there was nothing to parse. Docker image: read the mounted config again, restore gunicorn's logs, and let pip install into the venv #2811 (in v1.1.0) fixed that.ast, without running it. Only a top-level string literal assigned toFLEXMEASURES_ENVcounts, and the last one wins, as it does when the file runs. An expression is no longer mistaken for a string; a missing or unparsable file sets nothing here, and loading the config reports what is wrong with it, as before.FLEXMEASURES_ENVenvironment variable is set and the app is not in testing mode.documentation/changelog.rstHow to test
pytest flexmeasures/utils/tests/test_config_utils.pytest_flexmeasures_env_from_a_python_cfg_raises_no_dotenv_warningfails onmainwith the very warning from the logs (dotenv.main, "python-dotenv could not parse statement starting at line %s"), and passes here.test_read_flexmeasures_env_from_cfgcovers plain and annotated assignments, last-one-wins, expressions, an absent setting and a file that is not Python.Further Improvements
python-dotenv stays a dependency: the
flaskCLI uses it to read.flaskenv.This could go into a v1.1.1 patch release.
Related Items
Regression surfaced by #2811.
🤖 Generated with Claude Code