forked from VimPlug/jedi
successfully removed __str__ and __unicode__ methods from token.Token
This commit is contained in:
@@ -839,7 +839,8 @@ class Statement(Simple):
|
||||
|
||||
def get_code(self, new_line=True):
|
||||
def assemble(command_list, assignment=None):
|
||||
pieces = [c.get_code() if isinstance(c, Simple) else unicode(c)
|
||||
pieces = [c.get_code() if isinstance(c, Simple) else c.string if
|
||||
isinstance(c, tokenize.TokenInfo) else unicode(c)
|
||||
for c in command_list]
|
||||
if assignment is None:
|
||||
return ''.join(pieces)
|
||||
@@ -888,7 +889,8 @@ class Statement(Simple):
|
||||
|
||||
def is_global(self):
|
||||
# first keyword of the first token is global -> must be a global
|
||||
return str(self.token_list[0]) == "global"
|
||||
tok = self.token_list[0]
|
||||
return isinstance(tok, Name) and str(tok) == "global"
|
||||
|
||||
@property
|
||||
def assignment_details(self):
|
||||
@@ -976,7 +978,7 @@ class Statement(Simple):
|
||||
# it's not possible to set it earlier
|
||||
tok.parent = self
|
||||
else:
|
||||
tok = tok_temp.token
|
||||
tok = tok_temp.string
|
||||
start_tok_pos = tok_temp.start_pos
|
||||
last_end_pos = end_pos
|
||||
end_pos = tok_temp.end_pos
|
||||
@@ -1111,15 +1113,13 @@ class Statement(Simple):
|
||||
end_pos = tok.end_pos
|
||||
else:
|
||||
token_type = tok_temp.type
|
||||
tok = tok_temp.token
|
||||
tok = tok_temp.string
|
||||
start_pos = tok_temp.start_pos
|
||||
end_pos = tok_temp.end_pos
|
||||
if is_assignment(tok):
|
||||
# This means, there is an assignment here.
|
||||
# Add assignments, which can be more than one
|
||||
self._assignment_details.append(
|
||||
(result, tok_temp.token)
|
||||
)
|
||||
self._assignment_details.append((result, tok_temp.string))
|
||||
result = []
|
||||
is_chain = False
|
||||
continue
|
||||
|
||||
@@ -55,14 +55,6 @@ class Token(object):
|
||||
def __repr__(self):
|
||||
return "<%s: %s>" % (type(self).__name__, tuple(self))
|
||||
|
||||
# Backward compatibility py2
|
||||
def __unicode__(self):
|
||||
return self.string
|
||||
|
||||
# Backward compatibility py3
|
||||
def __str__(self):
|
||||
return self.string
|
||||
|
||||
# Backward compatibility
|
||||
def __getitem__(self, key):
|
||||
# Builds the same structure as tuple used to have
|
||||
@@ -99,7 +91,7 @@ class Token(object):
|
||||
def end_pos(self):
|
||||
"""Returns end position respecting multiline tokens."""
|
||||
end_pos_line = self.start_pos_line
|
||||
lines = unicode(self).split('\n')
|
||||
lines = self.string.split('\n')
|
||||
end_pos_line += len(lines) - 1
|
||||
end_pos_col = self.start_pos_col
|
||||
# Check for multiline token
|
||||
|
||||
Reference in New Issue
Block a user