Skip to content

Commit

Permalink
Always check for state
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktorn committed Jan 12, 2019
1 parent 860de83 commit ae08bd3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mypy/stubutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit ae08bd3

Please sign in to comment.