Add warnings filter suggestions to PEP 765 entry in What's New (#139658)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Docs (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Ubuntu SSL tests with AWS-LC (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
mypy / Run mypy on Lib/_pyrepl (push) Waiting to run
mypy / Run mypy on Lib/test/libregrtest (push) Waiting to run
mypy / Run mypy on Lib/tomllib (push) Waiting to run
mypy / Run mypy on Tools/build (push) Waiting to run
mypy / Run mypy on Tools/cases_generator (push) Waiting to run
mypy / Run mypy on Tools/clinic (push) Waiting to run
mypy / Run mypy on Tools/jit (push) Waiting to run
mypy / Run mypy on Tools/peg_generator (push) Waiting to run

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Alyssa Coghlan 2025-10-07 05:41:08 +10:00 committed by GitHub
parent 171f787a29
commit 331158065b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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`.
In situations where this change is inconvenient (such as those where the
warnings are redundant due to code linting), the :ref:`warning filter
<warning-filter>` can be used to turn off all syntax warnings by adding
``ignore::SyntaxWarning`` as a filter. This can 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``).
Note that applying such a filter at runtime using the :mod:`warnings` module
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 syntax warning.
(Contributed by Irit Katriel in :gh:`130080`.)