Skip to content

Commit a537452

Browse files
cdce8ppylint-backport[bot]
authored andcommitted
Suppress SyntaxWarnings for Python 3.14 when parsing modules (#2853)
(cherry picked from commit 8c4da6a)
1 parent bb38aa4 commit a537452

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ What's New in astroid 4.0.1?
1414
Release date: TBA
1515

1616

17+
* Suppress ``SyntaxWarning`` for invalid escape sequences and return in finally on
18+
Python 3.14 when parsing modules.
19+
1720

1821
What's New in astroid 4.0.0?
1922
============================

astroid/builder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from astroid import bases, modutils, nodes, raw_building, rebuilder, util
2525
from astroid._ast import ParserModule, get_parser_module
26-
from astroid.const import PY312_PLUS
26+
from astroid.const import PY312_PLUS, PY314_PLUS
2727
from astroid.exceptions import AstroidBuildingError, AstroidSyntaxError, InferenceError
2828

2929
if TYPE_CHECKING:
@@ -39,7 +39,11 @@
3939
_STATEMENT_SELECTOR = "#@"
4040

4141
if PY312_PLUS:
42-
warnings.filterwarnings("ignore", "invalid escape sequence", SyntaxWarning)
42+
warnings.filterwarnings("ignore", ".*invalid escape sequence", SyntaxWarning)
43+
if PY314_PLUS:
44+
warnings.filterwarnings(
45+
"ignore", "'(return|continue|break)' in a 'finally'", SyntaxWarning
46+
)
4347

4448

4549
def open_source_file(filename: str) -> tuple[TextIOWrapper, str, str]:

0 commit comments

Comments
 (0)