1
0
forked from VimPlug/jedi

* made Token readonly like a tuple by using @property

* end_pos calculation didn't respect multiline tokens
* replaced all index access to Token
* wrapped all code that injects token tuples with
  Token.from_tuple()
* repr of Token is still its tuple form!?
* PEP8 where I read or wrote code
This commit is contained in:
Jean-Louis Fuchs
2013-12-08 01:32:58 +01:00
parent 13680945d6
commit 3204a39f6c
5 changed files with 122 additions and 70 deletions

View File

@@ -392,18 +392,18 @@ class Parser(object):
first_tok = tok_list[0]
# docstrings
if len(tok_list) == 1 and not isinstance(first_tok, pr.Name) \
and first_tok[0] == tokenize.STRING:
and first_tok.token_type == tokenize.STRING:
# Normal docstring check
if self.freshscope and not self.no_docstr:
self._scope.add_docstr(first_tok[1])
self._scope.add_docstr(first_tok.token)
return None, tok
# Attribute docstring (PEP 224) support (sphinx uses it, e.g.)
# If string literal is being parsed...
elif first_tok[0] == tokenize.STRING:
elif first_tok.token_type == tokenize.STRING:
with common.ignored(IndexError, AttributeError):
# ...then set it as a docstring
self._scope.statements[-1].add_docstr(first_tok[1])
self._scope.statements[-1].add_docstr(first_tok.token)
return None, tok
stmt = stmt_class(self.module, tok_list, first_pos, self.end_pos,