Skip to content

Commit 5435a8a

Browse files
committed
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.
1 parent 69cfad0 commit 5435a8a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,19 @@ The compiler now emits a :exc:`SyntaxWarning` when a :keyword:`return`,
937937
leaving a :keyword:`finally` block.
938938
This change is specified in :pep:`765`.
939939

940+
For use cases where this change is inconvenient (such as those where the
941+
warnings are redundant due to code linting), syntax warnings specifically
942+
may be switched off via the :ref:`warning filter <warning-filter>`, using the
943+
clause ``ignore::SyntaxWarning``. This can also be specified in combination
944+
with a filter that converts other warnings to errors (for example, passing
945+
``-Werror -Wignore::SyntaxWarning`` as CLI options, or setting
946+
``PYTHONWARNINGS=error,ignore::SyntaxWarning``).
947+
948+
Note that applying such a filter at runtime (rather than via the interpreter's
949+
startup configuration) will only suppress the warning in code that is compiled
950+
*after* the filter is adjusted. Code that is compiled prior to the filter
951+
adjustment (for example, when a module is imported) will still emit the warning.
952+
940953
(Contributed by Irit Katriel in :gh:`130080`.)
941954

942955

0 commit comments

Comments
 (0)