Skip to content

Commit 075980b

Browse files
committed
Ignore warnings like: <type_comment>:1: SyntaxWarning: invalid escape sequence '\('
1 parent 54cd64d commit 075980b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mypy/semanal.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@
309309
from mypy.typevars import fill_typevars
310310
from mypy.util import correct_relative_import, is_dunder, module_prefix, unmangle, unnamed_function
311311
from mypy.visitor import NodeVisitor
312+
import warnings
312313

313314
T = TypeVar("T")
314315

@@ -7714,7 +7715,11 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> None:
77147715

77157716
self.errors = Errors(Options())
77167717
try:
7717-
t = self.expr_to_analyzed_type(maybe_type_expr)
7718+
# Ignore warnings that look like:
7719+
# <type_comment>:1: SyntaxWarning: invalid escape sequence '\('
7720+
with warnings.catch_warnings():
7721+
warnings.filterwarnings("ignore", category=SyntaxWarning)
7722+
t = self.expr_to_analyzed_type(maybe_type_expr)
77187723
if self.errors.is_errors():
77197724
t = None
77207725
except TypeTranslationError:

0 commit comments

Comments
 (0)