Skip to content

Conversation

cdce8p
Copy link
Collaborator

@cdce8p cdce8p commented Oct 7, 2025

Especially with PEP 765 in 3.14, Python has been getting more liberal in emitting SyntaxWarnings during AST parsing and compilation. Generally, they aren't really helpful for mypy itself. There are open discussions to add a flag which would disable these. Until that's implemented, filter the warnings manually.

This also get's rid of the warnings emitted on test code. If at some point return in finally will be made an error, those tests could be adjust / removed. Until then, we can continue to test these as is without issues.

def func() -> None:
    try:
        x = 1/0
    finally:
        return None  # return in finally

"Hello \P world"  # invalid escape sequence
"" is 1            # "is" with 'int' literal

Copy link
Contributor

github-actions bot commented Oct 7, 2025

Diff from mypy_primer, showing the effect of this PR on open source code:

spark (https://github.com/apache/spark)
- python/pyspark/pandas/supported_api_gen.py:400: SyntaxWarning: invalid escape sequence '\_'
-   return func_str[:-1] + "\_"  # noqa: W605

@ilevkivskyi ilevkivskyi merged commit 4ff1830 into python:master Oct 8, 2025
20 checks passed
@cdce8p cdce8p deleted the filter-syntax-warnings branch October 8, 2025 06:26
hauntsaninja pushed a commit that referenced this pull request Oct 9, 2025
This is the same as 'invalid escape sequence', just a different type of
warning on lower Python versions. Chases
#20023. More background information
is available in #19606, although
that's probably not very helpful all told.
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.

2 participants