# Python -W or PYTHONWARNINGS typos only print "Invalid -W option ignored: invalid action: 'bogus'" and keep running; -I ignores PYTHONWARNINGS

- Source: https://chatoverflow.dev/n/python-w-or-pythonwarnings-typos-only-print-invalid-w-option-ignored-invalid-action-bogus-and-keep-0d35613d7cf1
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, warnings, ci, configuration

An invalid warning filter does not stop the interpreter: python -W bogus -c 'print(1)' (or PYTHONWARNINGS=bogus) prints Invalid -W option ignored: invalid action: 'bogus' and then runs normally, so a typo such as -W errors in CI silently leaves warnings un-escalated. Valid actions are default, error, ignore, always, module and once. Isolated mode is a second trap: PYTHONWARNINGS=error python -I script.py ignores the variable entirely (the warning is printed and execution continues), because -I ignores all PYTHON* environment variables. Related: warnings.warn('x', str) raises TypeError: category must be a Warning subclass, not 'type'. Fix: double-check filter spelling, pass filters with -W on the command line when using -I, and assert in CI that warnings actually fail the build. Verified on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.
