forked from VimPlug/jedi
Remove is_py3 and is_py35
This commit is contained in:
@@ -18,8 +18,6 @@ from zipimport import zipimporter
|
||||
|
||||
from jedi.file_io import KnownContentFileIO, ZipFileIO
|
||||
|
||||
is_py3 = sys.version_info[0] >= 3
|
||||
is_py35 = is_py3 and sys.version_info[1] >= 5
|
||||
py_version = int(str(sys.version_info[0]) + str(sys.version_info[1]))
|
||||
|
||||
|
||||
@@ -105,7 +103,7 @@ def _from_loader(loader, string):
|
||||
except AttributeError:
|
||||
raise ImportError("get_source was not defined on loader")
|
||||
|
||||
if is_py3 and f is not importlib.machinery.SourceFileLoader.get_source:
|
||||
if f is not importlib.machinery.SourceFileLoader.get_source:
|
||||
# Unfortunately we are reading unicode here, not bytes.
|
||||
# It seems hard to get bytes, because the zip importer
|
||||
# logic just unpacks the zip file and returns a file descriptor
|
||||
@@ -143,7 +141,7 @@ class ImplicitNSInfo(object):
|
||||
self.paths = paths
|
||||
|
||||
|
||||
if is_py3:
|
||||
if True:
|
||||
all_suffixes = importlib.machinery.all_suffixes
|
||||
else:
|
||||
def all_suffixes():
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
|
||||
from jedi._compatibility import encoding, is_py3, u
|
||||
from jedi._compatibility import u
|
||||
|
||||
_inited = False
|
||||
|
||||
@@ -135,9 +135,4 @@ def print_to_stdout(color, str_out):
|
||||
"""
|
||||
col = getattr(Fore, color)
|
||||
_lazy_colorama_init()
|
||||
if not is_py3:
|
||||
str_out = str_out.encode(encoding, 'replace')
|
||||
print(col + str_out + Fore.RESET)
|
||||
|
||||
|
||||
# debug_function = print_to_stdout
|
||||
|
||||
10
test/run.py
10
test/run.py
@@ -114,7 +114,7 @@ import pytest
|
||||
|
||||
import jedi
|
||||
from jedi import debug
|
||||
from jedi._compatibility import unicode, is_py3
|
||||
from jedi._compatibility import unicode
|
||||
from jedi.api.classes import Name
|
||||
from jedi.api.completion import get_user_context
|
||||
from jedi import parser_utils
|
||||
@@ -401,12 +401,8 @@ def collect_dir_tests(base_dir, test_files, check_thirdparty=False):
|
||||
|
||||
path = os.path.join(base_dir, f_name)
|
||||
|
||||
if is_py3:
|
||||
with open(path, encoding='utf-8', newline='') as f:
|
||||
source = f.read()
|
||||
else:
|
||||
with open(path) as f:
|
||||
source = unicode(f.read(), 'UTF-8')
|
||||
with open(path, encoding='utf-8', newline='') as f:
|
||||
source = f.read()
|
||||
|
||||
for case in collect_file_tests(path, StringIO(source),
|
||||
lines_to_execute):
|
||||
|
||||
@@ -7,7 +7,7 @@ import warnings
|
||||
import pytest
|
||||
|
||||
import jedi
|
||||
from jedi._compatibility import is_py3, py_version
|
||||
from jedi._compatibility import py_version
|
||||
from jedi.inference.compiled import mixed
|
||||
from importlib import import_module
|
||||
|
||||
@@ -139,9 +139,7 @@ def test_complete_raw_module():
|
||||
def test_complete_raw_instance():
|
||||
import datetime
|
||||
dt = datetime.datetime(2013, 1, 1)
|
||||
completions = ['time', 'timetz', 'timetuple']
|
||||
if is_py3:
|
||||
completions += ['timestamp']
|
||||
completions = ['time', 'timetz', 'timetuple', 'timestamp']
|
||||
_assert_interpreter_complete('(dt - dt).ti', locals(), completions)
|
||||
|
||||
|
||||
@@ -349,12 +347,10 @@ def test_keyword_argument():
|
||||
assert c.name == 'some_keyword_argument='
|
||||
assert c.complete == 'ord_argument='
|
||||
|
||||
# This needs inspect.signature to work.
|
||||
if is_py3:
|
||||
# Make it impossible for jedi to find the source of the function.
|
||||
f.__name__ = 'xSOMETHING'
|
||||
c, = jedi.Interpreter("x(some_keyw", [{'x': f}]).complete()
|
||||
assert c.name == 'some_keyword_argument='
|
||||
# Make it impossible for jedi to find the source of the function.
|
||||
f.__name__ = 'xSOMETHING'
|
||||
c, = jedi.Interpreter("x(some_keyw", [{'x': f}]).complete()
|
||||
assert c.name == 'some_keyword_argument='
|
||||
|
||||
|
||||
def test_more_complex_instances():
|
||||
@@ -403,16 +399,12 @@ def test_dir_magic_method(allow_unsafe_getattr):
|
||||
raise AttributeError(name)
|
||||
|
||||
def __dir__(self):
|
||||
if is_py3:
|
||||
names = object.__dir__(self)
|
||||
else:
|
||||
names = dir(object())
|
||||
return ['foo', 'bar'] + names
|
||||
return ['foo', 'bar'] + object.__dir__(self)
|
||||
|
||||
itp = jedi.Interpreter("ca.", [{'ca': CompleteAttrs()}])
|
||||
completions = itp.complete()
|
||||
names = [c.name for c in completions]
|
||||
assert ('__dir__' in names) == is_py3
|
||||
assert ('__dir__' in names) is True
|
||||
assert '__class__' in names
|
||||
assert 'foo' in names
|
||||
assert 'bar' in names
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from jedi._compatibility import is_py3
|
||||
from jedi import parser_utils
|
||||
from parso import parse
|
||||
from parso.python import tree
|
||||
@@ -55,10 +54,7 @@ def test_hex_values_in_docstring():
|
||||
'''
|
||||
|
||||
doc = parser_utils.clean_scope_docstring(next(parse(source).iter_funcdefs()))
|
||||
if is_py3:
|
||||
assert doc == '\xff'
|
||||
else:
|
||||
assert doc == u'<EFBFBD>'
|
||||
assert doc == '\xff'
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user