Skip to content

Accept level names in any case - #210

Closed
sappelhoff wants to merge 1 commit into
mainfrom
case-insensitive-levels
Closed

Accept level names in any case#210
sappelhoff wants to merge 1 commit into
mainfrom
case-insensitive-levels

Conversation

@sappelhoff

Copy link
Copy Markdown
Owner

setup_logging("warning") raised, because the stdlib only knows upper-case level names:

>>> pyprep.setup_logging("warning")
ValueError: Unknown level: 'warning'

mne.set_log_level("warning") accepts it, lower case is the spelling people reach for, and it
is what the sibling packages in this stack show in their docs. So the level is upper-cased when
it is a string, and passed through untouched when it is an int.

Tested for "warning", "WARNING", "Warning" and logging.WARNING.

pytest tests/test_logging.py: 57 passed. ruff check clean.

The stdlib only knows upper-case level names, so setup_logging("warning")
raised ValueError: Unknown level: 'warning'. MNE accepts any case for the same
argument, and so should we -- lower case is the spelling people reach for, and
it is what the docs of the sibling packages in this stack now show.
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.92%. Comparing base (e252bf4) to head (bd3d17e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #210   +/-   ##
=======================================
  Coverage   97.92%   97.92%           
=======================================
  Files           8        8           
  Lines         869      869           
=======================================
  Hits          851      851           
  Misses         18       18           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sappelhoff

Copy link
Copy Markdown
Owner Author

Superseded by #211, which folds this level.upper() fix into a new _as_level helper as part of making pyprep quiet by default. The changelog entry is reworked there.

@sappelhoff sappelhoff closed this Aug 21, 2026
@sappelhoff
sappelhoff deleted the case-insensitive-levels branch August 21, 2026 06:43
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