Skip to content

Commit 8c4da6a

Browse files
authored
Suppress SyntaxWarnings for Python 3.14 when parsing modules (#2853)
1 parent 7fce264 commit 8c4da6a

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
@@ -21,6 +21,9 @@ Release date: TBA
2121

2222
* Make `type.__new__()` raise clear errors instead of returning `None`
2323

24+
* Suppress ``SyntaxWarning`` for invalid escape sequences and return in finally on
25+
Python 3.14 when parsing modules.
26+
2427

2528
What's New in astroid 4.0.0?
2629
============================

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)