mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-09 22:25:53 +08:00
Remove exact_type from PythonToken, because the support for this differentiation of exact_type and type was never really there.
This commit is contained in:
@@ -212,25 +212,14 @@ class Token(namedtuple('Token', ['type', 'string', 'start_pos', 'prefix'])):
|
|||||||
else:
|
else:
|
||||||
return self.start_pos[0], self.start_pos[1] + len(self.string)
|
return self.start_pos[0], self.start_pos[1] + len(self.string)
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return ('TokenInfo(type=%s, string=%r, start=%r, prefix=%r)' %
|
|
||||||
self._replace(type=self.get_type_name()))
|
|
||||||
|
|
||||||
|
|
||||||
class PythonToken(Token):
|
class PythonToken(Token):
|
||||||
def get_type_name(self, exact=True):
|
def get_type_name(self, exact=True):
|
||||||
if exact:
|
return tok_name[self.type]
|
||||||
typ = self.exact_type
|
|
||||||
else:
|
|
||||||
typ = self.type
|
|
||||||
return tok_name[typ]
|
|
||||||
|
|
||||||
@property
|
def __repr__(self):
|
||||||
def exact_type(self):
|
return ('TokenInfo(type=%s, string=%r, start=%r, prefix=%r)' %
|
||||||
if self.type == OP and self.string in opmap:
|
self._replace(type=self.get_type_name()))
|
||||||
return opmap[self.string]
|
|
||||||
else:
|
|
||||||
return self.type
|
|
||||||
|
|
||||||
|
|
||||||
def tokenize(code, version_info):
|
def tokenize(code, version_info):
|
||||||
|
|||||||
Reference in New Issue
Block a user