Skip to content

Stop python-dotenv warning about flexmeasures.cfg on startup - #2845

Open
Flix6x wants to merge 2 commits into
mainfrom
fix/cfg-dotenv-warning
Open

Flix6x wants to merge 2 commits into
mainfrom
fix/cfg-dotenv-warning

Conversation

@Flix6x

@Flix6x Flix6x commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Description

Since v1.1.0, every container of the Docker image logs WARNING: python-dotenv could not parse statement starting at line 1 on startup.

How to test

pytest flexmeasures/utils/tests/test_config_utils.py

  • test_flexmeasures_env_from_a_python_cfg_raises_no_dotenv_warning fails on main with 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_cfg covers 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 flask CLI 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

Flix6x and others added 2 commits November 9, 2026 12:43
…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>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 flexmeasures | 🛠️ Build #35752641 | 📁 Comparing fa6b1cb against latest (055d54d)

  🔍 Preview build  

4 files changed
± changelog.html
± genindex.html
± _autosummary/flexmeasures.utils.config_utils.html
± api/v3_0.html

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant