Skip to content

Commit 36a89c0

Browse files
committed
Filter SyntaxWarnings during AST parsing
1 parent f2ebd79 commit 36a89c0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mypy/fastparse.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,12 @@ def parse(
232232
assert options.python_version[0] >= 3
233233
feature_version = options.python_version[1]
234234
try:
235-
# Disable deprecation warnings about \u
235+
# Disable
236+
# - deprecation warnings about \u
237+
# - syntax warnings for 'invalid escape sequence' (3.12+) and 'return in finally' (3.14+)
236238
with warnings.catch_warnings():
237239
warnings.filterwarnings("ignore", category=DeprecationWarning)
240+
warnings.filterwarnings("ignore", category=SyntaxWarning)
238241
ast = ast3_parse(source, fnam, "exec", feature_version=feature_version)
239242

240243
tree = ASTConverter(

pyproject.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ xfail_strict = true
227227
# Force warnings as errors
228228
filterwarnings = [
229229
"error",
230-
# Some testcases may contain code that emits SyntaxWarnings, and they are not yet
231-
# handled consistently in 3.14 (PEP 765)
232-
"default::SyntaxWarning",
233230
]
234231

235232
[tool.coverage.run]

0 commit comments

Comments
 (0)