Skip to content

Commit ae08bd3

Browse files
committed
Always check for state
1 parent 860de83 commit ae08bd3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mypy/stubutil.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ def infer_sig_from_docstring(docstr: str, name: str) -> Optional[List[TypedFunct
162162
# reset state, function name not followed by '('
163163
state.pop()
164164

165-
elif token.type == tokenize.OP and token.string in ('[', '(', '{'):
165+
elif token.type == tokenize.OP and token.string in ('[', '(', '{') and \
166+
state[-1] != State.INIT:
166167
accumulator += token.string
167168
state.append(State.OPEN_BRACKET)
168169

@@ -206,7 +207,7 @@ def infer_sig_from_docstring(docstr: str, name: str) -> Optional[List[TypedFunct
206207
arg_default = None
207208
accumulator = ""
208209

209-
elif token.type == tokenize.OP and token.string == '->':
210+
elif token.type == tokenize.OP and token.string == '->' and state[-1] == State.INIT:
210211
accumulator = ""
211212
state.append(State.RETURN_VALUE)
212213

0 commit comments

Comments
 (0)