From ae08bd3e477f960455a02adf12d085b2249b6251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Thu, 20 Dec 2018 09:25:04 +0100 Subject: [PATCH] Always check for state --- mypy/stubutil.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mypy/stubutil.py b/mypy/stubutil.py index 08f6029d7d2b..9a9aab38976c 100644 --- a/mypy/stubutil.py +++ b/mypy/stubutil.py @@ -162,7 +162,8 @@ def infer_sig_from_docstring(docstr: str, name: str) -> Optional[List[TypedFunct # reset state, function name not followed by '(' state.pop() - elif token.type == tokenize.OP and token.string in ('[', '(', '{'): + elif token.type == tokenize.OP and token.string in ('[', '(', '{') and \ + state[-1] != State.INIT: accumulator += token.string state.append(State.OPEN_BRACKET) @@ -206,7 +207,7 @@ def infer_sig_from_docstring(docstr: str, name: str) -> Optional[List[TypedFunct arg_default = None accumulator = "" - elif token.type == tokenize.OP and token.string == '->': + elif token.type == tokenize.OP and token.string == '->' and state[-1] == State.INIT: accumulator = "" state.append(State.RETURN_VALUE)