Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
PEP 765: What's New warnings filter suggestions
For CI use cases where static code analysis is in use,
emitting SyntaxWarnings is essentially redundant.

Accordingly, there's no harm in suggesting that folks
turn them off to avoid poor interactions between PEP 765
and treating warnings as errors.
  • Loading branch information
ncoghlan committed Oct 6, 2025
commit 5435a8a9d928b96c5731774779684f41d57331da
13 changes: 13 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,19 @@ The compiler now emits a :exc:`SyntaxWarning` when a :keyword:`return`,
leaving a :keyword:`finally` block.
This change is specified in :pep:`765`.

For use cases where this change is inconvenient (such as those where the
Comment thread
ncoghlan marked this conversation as resolved.
Outdated
warnings are redundant due to code linting), syntax warnings specifically
may be switched off via the :ref:`warning filter <warning-filter>`, using the
clause ``ignore::SyntaxWarning``. This can also be specified in combination
with a filter that converts other warnings to errors (for example, passing
``-Werror -Wignore::SyntaxWarning`` as CLI options, or setting
``PYTHONWARNINGS=error,ignore::SyntaxWarning``).
Comment thread
ncoghlan marked this conversation as resolved.
Outdated

Note that applying such a filter at runtime (rather than via the interpreter's
startup configuration) will only suppress the warning in code that is compiled
*after* the filter is adjusted. Code that is compiled prior to the filter
adjustment (for example, when a module is imported) will still emit the warning.
Comment thread
ncoghlan marked this conversation as resolved.
Outdated

Comment thread
ncoghlan marked this conversation as resolved.
(Contributed by Irit Katriel in :gh:`130080`.)


Expand Down
Loading