mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 21:54:54 +08:00
Use the _compatibility file in parso.
This commit is contained in:
@@ -10,7 +10,7 @@ import errno
|
||||
|
||||
from jedi import settings
|
||||
from jedi import debug
|
||||
from jedi._compatibility import FileNotFoundError
|
||||
from parso._compatibility import FileNotFoundError
|
||||
|
||||
|
||||
_PICKLE_VERSION = 30
|
||||
|
||||
@@ -5,7 +5,7 @@ import os
|
||||
|
||||
from jedi import settings
|
||||
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.python.parser import Parser, _remove_last_newline
|
||||
from parso.python.diff import DiffParser
|
||||
|
||||
@@ -25,7 +25,7 @@ Any subclasses of :class:`Scope`, including :class:`Module` has an attribute
|
||||
[<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, \
|
||||
search_ancestor
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from jedi._compatibility import is_py3, is_py35
|
||||
from parso._compatibility import py_version
|
||||
from token import *
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ NL = N_TOKENS
|
||||
tok_name[NL] = 'NL'
|
||||
N_TOKENS += 1
|
||||
|
||||
if is_py3:
|
||||
if py_version >= 30:
|
||||
BACKQUOTE = N_TOKENS
|
||||
tok_name[BACKQUOTE] = 'BACKQUOTE'
|
||||
N_TOKENS += 1
|
||||
@@ -24,7 +24,7 @@ else:
|
||||
tok_name[ELLIPSIS] = 'ELLIPSIS'
|
||||
N_TOKENS += 1
|
||||
|
||||
if not is_py35:
|
||||
if not py_version >= 35:
|
||||
ATEQUAL = N_TOKENS
|
||||
tok_name[ATEQUAL] = 'ATEQUAL'
|
||||
N_TOKENS += 1
|
||||
|
||||
@@ -18,14 +18,14 @@ import itertools as _itertools
|
||||
|
||||
from parso.token import (tok_name, N_TOKENS, ENDMARKER, STRING, NUMBER, opmap,
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
is_identifier = str.isidentifier
|
||||
else:
|
||||
@@ -73,7 +73,7 @@ if py_version >= 36:
|
||||
else:
|
||||
Hexnumber = r'0[xX][0-9a-fA-F]+'
|
||||
Binnumber = r'0[bB][01]+'
|
||||
if is_py3:
|
||||
if py_version >= 30:
|
||||
Octnumber = r'0[oO][0-7]+'
|
||||
else:
|
||||
Octnumber = '0[0-7]+'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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):
|
||||
@@ -283,7 +283,7 @@ class BaseNode(NodeOrLeaf):
|
||||
@utf8_repr
|
||||
def __repr__(self):
|
||||
code = self.get_code().replace('\n', ' ').strip()
|
||||
if not is_py3:
|
||||
if not py_version >= 30:
|
||||
code = code.encode(encoding, 'replace')
|
||||
return "<%s: %s@%s,%s>" % \
|
||||
(type(self).__name__, code, self.start_pos[0], self.start_pos[1])
|
||||
|
||||
Reference in New Issue
Block a user