Skip to content

Commit 882e37e

Browse files
JukkaLilevkivskyi
authored andcommitted
Silence deprecation warning from typed-ast in tests (#7335)
This fixes a deprecation warning about `<>` in Python 2 that came up every time the full test suite was run.
1 parent 17a93ea commit 882e37e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy/fastparse2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
two in a typesafe way.
1616
"""
1717
import sys
18+
import warnings
1819

1920
import typing # for typing.Type, which conflicts with types.Type
2021
from typing import Tuple, Union, TypeVar, Callable, Sequence, Optional, Any, Dict, cast, List
@@ -106,7 +107,10 @@ def parse(source: Union[str, bytes],
106107
is_stub_file = fnam.endswith('.pyi')
107108
try:
108109
assert options.python_version[0] < 3 and not is_stub_file
109-
ast = ast27.parse(source, fnam, 'exec')
110+
# Disable deprecation warnings about <>.
111+
with warnings.catch_warnings():
112+
warnings.filterwarnings("ignore", category=DeprecationWarning)
113+
ast = ast27.parse(source, fnam, 'exec')
110114
tree = ASTConverter(options=options,
111115
errors=errors,
112116
).visit(ast)

0 commit comments

Comments
 (0)