From 36a89c02a9e9e34b1d97bb1077ffe6c724d68409 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Wed, 8 Oct 2025 01:32:13 +0200 Subject: [PATCH] Filter SyntaxWarnings during AST parsing --- mypy/fastparse.py | 5 ++++- pyproject.toml | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mypy/fastparse.py b/mypy/fastparse.py index 6b2eb532003c..aa5c89cd0f41 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -232,9 +232,12 @@ def parse( assert options.python_version[0] >= 3 feature_version = options.python_version[1] try: - # Disable deprecation warnings about \u + # Disable + # - deprecation warnings about \u + # - syntax warnings for 'invalid escape sequence' (3.12+) and 'return in finally' (3.14+) with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) + warnings.filterwarnings("ignore", category=SyntaxWarning) ast = ast3_parse(source, fnam, "exec", feature_version=feature_version) tree = ASTConverter( diff --git a/pyproject.toml b/pyproject.toml index adcca65bf015..96b05ba459b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -227,9 +227,6 @@ xfail_strict = true # Force warnings as errors filterwarnings = [ "error", - # Some testcases may contain code that emits SyntaxWarnings, and they are not yet - # handled consistently in 3.14 (PEP 765) - "default::SyntaxWarning", ] [tool.coverage.run]