Skip to content

Commit

Permalink
fix: do not override user-specified warnings filter
Browse files Browse the repository at this point in the history
Currently the Lektor CLI unconditionally sets the warnings filter to
"default". There is no way of the user to configure this.

Here we bypass re-configuring the warnings filter if it has already
been customized, either via the PYTHONWARNINGS environment variable or
by python's -W flag.

E.g., now one can show all warnings by doing either of:

    PYTHONWARNINGS=always lektor build

or

    python -W always -m lektor build

Ref: https://docs.python.org/3/library/warnings.html#overriding-the-default-filter
  • Loading branch information
dairiki committed Apr 21, 2023
1 parent 7960115 commit e2d0274
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lektor/cli.py
Expand Up @@ -42,7 +42,8 @@ def cli(ctx, project=None, language=None):
This command can invoke lektor locally and serve up the website. It's
intended for local development of websites.
"""
warnings.simplefilter("default")
if not sys.warnoptions:
warnings.simplefilter("default")
if language is not None:
ctx.ui_lang = language
if project is not None:
Expand Down

0 comments on commit e2d0274

Please sign in to comment.