Use the _compatibility file in parso.

This commit is contained in:
Dave Halter
2017-05-11 16:30:38 -04:00
parent a2cae8f5c5
commit efac51c1b1
6 changed files with 11 additions and 11 deletions

View File

@@ -10,7 +10,7 @@ import errno
from jedi import settings from jedi import settings
from jedi import debug from jedi import debug
from jedi._compatibility import FileNotFoundError from parso._compatibility import FileNotFoundError
_PICKLE_VERSION = 30 _PICKLE_VERSION = 30

View File

@@ -5,7 +5,7 @@ import os
from jedi import settings from jedi import settings
from jedi.common import splitlines, source_to_unicode from jedi.common import splitlines, source_to_unicode
from jedi._compatibility import FileNotFoundError from parso._compatibility import FileNotFoundError
from parso.pgen2.pgen import generate_grammar from parso.pgen2.pgen import generate_grammar
from parso.python.parser import Parser, _remove_last_newline from parso.python.parser import Parser, _remove_last_newline
from parso.python.diff import DiffParser from parso.python.diff import DiffParser

View File

@@ -25,7 +25,7 @@ Any subclasses of :class:`Scope`, including :class:`Module` has an attribute
[<ImportName: import os@1,0>] [<ImportName: import os@1,0>]
""" """
from jedi._compatibility import utf8_repr, unicode from parso._compatibility import utf8_repr, unicode
from parso.tree import Node, BaseNode, Leaf, ErrorNode, ErrorLeaf, \ from parso.tree import Node, BaseNode, Leaf, ErrorNode, ErrorLeaf, \
search_ancestor search_ancestor

View File

@@ -1,6 +1,6 @@
from __future__ import absolute_import from __future__ import absolute_import
from jedi._compatibility import is_py3, is_py35 from parso._compatibility import py_version
from token import * from token import *
@@ -12,7 +12,7 @@ NL = N_TOKENS
tok_name[NL] = 'NL' tok_name[NL] = 'NL'
N_TOKENS += 1 N_TOKENS += 1
if is_py3: if py_version >= 30:
BACKQUOTE = N_TOKENS BACKQUOTE = N_TOKENS
tok_name[BACKQUOTE] = 'BACKQUOTE' tok_name[BACKQUOTE] = 'BACKQUOTE'
N_TOKENS += 1 N_TOKENS += 1
@@ -24,7 +24,7 @@ else:
tok_name[ELLIPSIS] = 'ELLIPSIS' tok_name[ELLIPSIS] = 'ELLIPSIS'
N_TOKENS += 1 N_TOKENS += 1
if not is_py35: if not py_version >= 35:
ATEQUAL = N_TOKENS ATEQUAL = N_TOKENS
tok_name[ATEQUAL] = 'ATEQUAL' tok_name[ATEQUAL] = 'ATEQUAL'
N_TOKENS += 1 N_TOKENS += 1

View File

@@ -18,14 +18,14 @@ import itertools as _itertools
from parso.token import (tok_name, N_TOKENS, ENDMARKER, STRING, NUMBER, opmap, from parso.token import (tok_name, N_TOKENS, ENDMARKER, STRING, NUMBER, opmap,
NAME, OP, ERRORTOKEN, NEWLINE, INDENT, DEDENT) NAME, OP, ERRORTOKEN, NEWLINE, INDENT, DEDENT)
from jedi._compatibility import is_py3, py_version, u from parso._compatibility import py_version, u
from jedi.common import splitlines from jedi.common import splitlines
cookie_re = re.compile("coding[:=]\s*([-\w.]+)") cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
if is_py3: if py_version >= 30:
# Python 3 has str.isidentifier() to check if a char is a valid identifier # Python 3 has str.isidentifier() to check if a char is a valid identifier
is_identifier = str.isidentifier is_identifier = str.isidentifier
else: else:
@@ -73,7 +73,7 @@ if py_version >= 36:
else: else:
Hexnumber = r'0[xX][0-9a-fA-F]+' Hexnumber = r'0[xX][0-9a-fA-F]+'
Binnumber = r'0[bB][01]+' Binnumber = r'0[bB][01]+'
if is_py3: if py_version >= 30:
Octnumber = r'0[oO][0-7]+' Octnumber = r'0[oO][0-7]+'
else: else:
Octnumber = '0[0-7]+' Octnumber = '0[0-7]+'

View File

@@ -1,5 +1,5 @@
from abc import abstractmethod, abstractproperty from abc import abstractmethod, abstractproperty
from jedi._compatibility import utf8_repr, encoding, is_py3 from parso._compatibility import utf8_repr, encoding, py_version
def search_ancestor(node, *node_types): def search_ancestor(node, *node_types):
@@ -283,7 +283,7 @@ class BaseNode(NodeOrLeaf):
@utf8_repr @utf8_repr
def __repr__(self): def __repr__(self):
code = self.get_code().replace('\n', ' ').strip() code = self.get_code().replace('\n', ' ').strip()
if not is_py3: if not py_version >= 30:
code = code.encode(encoding, 'replace') code = code.encode(encoding, 'replace')
return "<%s: %s@%s,%s>" % \ return "<%s: %s@%s,%s>" % \
(type(self).__name__, code, self.start_pos[0], self.start_pos[1]) (type(self).__name__, code, self.start_pos[0], self.start_pos[1])