Drop support for EOL Python 2.6

This commit is contained in:
Hugo
2018-01-05 10:17:38 +02:00
parent 0334918d73
commit 7c31ea9042
19 changed files with 13 additions and 82 deletions

View File

@@ -1,7 +1,6 @@
language: python language: python
sudo: false sudo: false
python: python:
- 2.6
- 2.7 - 2.7
- 3.3 - 3.3
- 3.4 - 3.4

View File

@@ -96,7 +96,7 @@ understands, see: `Features
<https://jedi.readthedocs.org/en/latest/docs/features.html>`_. A list of <https://jedi.readthedocs.org/en/latest/docs/features.html>`_. A list of
caveats can be found on the same page. caveats can be found on the same page.
You can run Jedi on cPython 2.6, 2.7, 3.3, 3.4 or 3.5 but it should also You can run Jedi on CPython 2.7 or 3.3+ but it should also
understand/parse code older than those versions. understand/parse code older than those versions.
Tips on how to use Jedi efficiently can be found `here Tips on how to use Jedi efficiently can be found `here

View File

@@ -20,7 +20,7 @@ make it work.
General Features General Features
---------------- ----------------
- python 2.6+ and 3.3+ support - Python 2.7 and 3.3+ support
- ignores syntax errors and wrong indentation - ignores syntax errors and wrong indentation
- can deal with complex module / function / class structures - can deal with complex module / function / class structures
- virtualenv support - virtualenv support
@@ -64,7 +64,7 @@ Not yet implemented:
- manipulations of instances outside the instance variables without using - manipulations of instances outside the instance variables without using
methods methods
- implicit namespace packages (Python 3.3+, `PEP 420 <https://www.python.org/dev/peps/pep-0420/>`_) - implicit namespace packages (Python 3.4+, `PEP 420 <https://www.python.org/dev/peps/pep-0420/>`_)
Will probably never be implemented: Will probably never be implemented:
@@ -88,7 +88,7 @@ etc.
**Security** **Security**
Security is an important issue for |jedi|. Therefore no Python code is Security is an important issue for |jedi|. Therefore no Python code is
executed. As long as you write pure python, everything is evaluated executed. As long as you write pure Python, everything is evaluated
statically. But: If you use builtin modules (``c_builtin``) there is no other statically. But: If you use builtin modules (``c_builtin``) there is no other
option than to execute those modules. However: Execute isn't that critical (as option than to execute those modules. However: Execute isn't that critical (as
e.g. in pythoncomplete, which used to execute *every* import!), because it e.g. in pythoncomplete, which used to execute *every* import!), because it
@@ -117,7 +117,7 @@ one of the following docstring/annotation syntax styles:
https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0484/
function annotations (python 3 only; python 2 function annotations with function annotations (Python 3 only; Python 2 function annotations with
comments in planned but not yet implemented) comments in planned but not yet implemented)
:: ::
@@ -129,7 +129,7 @@ comments in planned but not yet implemented)
node.| # complete here node.| # complete here
assignment, for-loop and with-statement type hints (all python versions). assignment, for-loop and with-statement type hints (all Python versions).
Note that the type hints must be on the same line as the statement Note that the type hints must be on the same line as the statement
:: ::
@@ -142,7 +142,7 @@ Note that the type hints must be on the same line as the statement
print(f + 3) print(f + 3)
Most of the features in PEP-0484 are supported including the typing module Most of the features in PEP-0484 are supported including the typing module
(for python < 3.5 you have to do ``pip install typing`` to use these), (for Python < 3.5 you have to do ``pip install typing`` to use these),
and forward references. and forward references.
Things that are missing (and this is not an exhaustive list; some of these Things that are missing (and this is not an exhaustive list; some of these

View File

@@ -1,5 +1,5 @@
""" """
To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been To ensure compatibility from Python ``2.7`` - ``3.x``, a module has been
created. Clearly there is huge need to use conforming syntax. created. Clearly there is huge need to use conforming syntax.
""" """
import sys import sys
@@ -13,13 +13,10 @@ try:
except ImportError: except ImportError:
pass pass
# Cannot use sys.version.major and minor names, because in Python 2.6 it's not
# a namedtuple.
is_py3 = sys.version_info[0] >= 3 is_py3 = sys.version_info[0] >= 3
is_py33 = is_py3 and sys.version_info[1] >= 3 is_py33 = is_py3 and sys.version_info[1] >= 3
is_py34 = is_py3 and sys.version_info[1] >= 4 is_py34 = is_py3 and sys.version_info[1] >= 4
is_py35 = is_py3 and sys.version_info[1] >= 5 is_py35 = is_py3 and sys.version_info[1] >= 5
is_py26 = not is_py3 and sys.version_info[1] < 7
py_version = int(str(sys.version_info[0]) + str(sys.version_info[1])) py_version = int(str(sys.version_info[0]) + str(sys.version_info[1]))
@@ -127,14 +124,7 @@ def find_module_pre_py33(string, path=None, fullname=None):
if loader: if loader:
is_package = loader.is_package(string) is_package = loader.is_package(string)
is_archive = hasattr(loader, 'archive') is_archive = hasattr(loader, 'archive')
try: module_path = loader.get_filename(string)
module_path = loader.get_filename(string)
except AttributeError:
# fallback for py26
try:
module_path = loader._get_filename(string)
except AttributeError:
continue
if is_package: if is_package:
module_path = os.path.dirname(module_path) module_path = os.path.dirname(module_path)
if is_archive: if is_archive:
@@ -242,11 +232,6 @@ import ast
def literal_eval(string): def literal_eval(string):
# py3.0, py3.1 and py32 don't support unicode literals. Support those, I
# don't want to write two versions of the tokenizer.
if is_py3 and sys.version_info.minor < 3:
if re.match('[uU][\'"]', string):
string = string[1:]
return ast.literal_eval(string) return ast.literal_eval(string)

View File

@@ -256,13 +256,7 @@ def collections_namedtuple(evaluator, obj, arguments):
This has to be done by processing the namedtuple class template and This has to be done by processing the namedtuple class template and
evaluating the result. evaluating the result.
.. note:: |jedi| only supports namedtuples on Python >2.6.
""" """
# Namedtuples are not supported on Python 2.6
if not hasattr(collections, '_class_template'):
return NO_CONTEXTS
# Process arguments # Process arguments
# TODO here we only use one of the types, we should use all. # TODO here we only use one of the types, we should use all.
name = list(_follow_param(evaluator, arguments, 0))[0].obj name = list(_follow_param(evaluator, arguments, 0))[0].obj

View File

@@ -44,7 +44,6 @@ setup(name='jedi',
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.3',

View File

@@ -403,8 +403,6 @@ def test_func():
x x
# python >= 2.7
# Set literals are not valid in 2.6.
#? int() #? int()
tuple({1})[0] tuple({1})[0]

View File

@@ -286,8 +286,6 @@ with open('') as f:
#? str() #? str()
line line
# Nested with statements don't exist in Python 2.6.
# python >= 2.7
with open('') as f1, open('') as f2: with open('') as f1, open('') as f2:
#? ['closed'] #? ['closed']
f1.closed f1.closed

View File

@@ -210,6 +210,5 @@ d[2]
next(iter({a for a in range(10)})) next(iter({a for a in range(10)}))
# with a set literal (also doesn't work in 2.6).
#? int() #? int()
[a for a in {1, 2, 3}][0] [a for a in {1, 2, 3}][0]

View File

@@ -288,8 +288,6 @@ third()[0]
# ----------------- # -----------------
# set.add # set.add
# ----------------- # -----------------
# Set literals are not valid in 2.6.
# python >= 2.7
st = {1.0} st = {1.0}
for a in [1,2]: for a in [1,2]:
st.add(a) st.add(a)

View File

@@ -47,10 +47,6 @@ b
class Employee: class Employee:
pass pass
# The typing library is not installable for Python 2.6, therefore ignore the
# following tests.
# python >= 2.7
from typing import List from typing import List
x = [] # type: List[Employee] x = [] # type: List[Employee]
#? Employee() #? Employee()

View File

@@ -3,8 +3,6 @@ Test the typing library, with docstrings. This is needed since annotations
are not supported in python 2.7 else then annotating by comment (and this is are not supported in python 2.7 else then annotating by comment (and this is
still TODO at 2016-01-23) still TODO at 2016-01-23)
""" """
# There's no Python 2.6 typing module.
# python >= 2.7
import typing import typing
class B: class B:
pass pass

View File

@@ -116,8 +116,6 @@ tup4.index
# ----------------- # -----------------
# set # set
# ----------------- # -----------------
# Set literals are not valid in 2.6.
# python >= 2.7
set_t = {1,2} set_t = {1,2}
#? ['clear', 'copy'] #? ['clear', 'copy']

View File

@@ -296,8 +296,6 @@ x = 32
[x for x in something] [x for x in something]
x = 3 x = 3
# Not supported syntax in Python 2.6.
# python >= 2.7
#< 1 (0,1), (0,10) #< 1 (0,1), (0,10)
{x:1 for x in something} {x:1 for x in something}
#< 10 (0,1), (0,10) #< 10 (0,1), (0,10)

View File

@@ -13,7 +13,6 @@ from jedi._compatibility import find_module_py33, find_module
from ..helpers import cwd_at from ..helpers import cwd_at
from jedi import Script from jedi import Script
from jedi._compatibility import is_py26
@pytest.mark.skipif('sys.version_info < (3,3)') @pytest.mark.skipif('sys.version_info < (3,3)')
@@ -47,7 +46,6 @@ def test_find_module_package_zipped():
assert len(jedi.Script('import pkg; pkg.mod', 1, 19).completions()) == 1 assert len(jedi.Script('import pkg; pkg.mod', 1, 19).completions()) == 1
@pytest.mark.skipif('sys.version_info < (2,7)')
def test_find_module_not_package_zipped(): def test_find_module_not_package_zipped():
if 'zipped_imports/not_pkg.zip' not in sys.path: if 'zipped_imports/not_pkg.zip' not in sys.path:
sys.path.append(os.path.join(os.path.dirname(__file__), sys.path.append(os.path.join(os.path.dirname(__file__),
@@ -160,8 +158,7 @@ def test_complete_on_empty_import():
wanted = set(['ImportError', 'import', 'ImportWarning']) wanted = set(['ImportError', 'import', 'ImportWarning'])
assert set([c.name for c in Script("import").completions()]) == wanted assert set([c.name for c in Script("import").completions()]) == wanted
if not is_py26: # python 2.6 doesn't always come with a library `import*`. assert len(Script("import import", path='').completions()) > 0
assert len(Script("import import", path='').completions()) > 0
# 111 # 111
assert Script("from datetime import").completions()[0].name == 'import' assert Script("from datetime import").completions()[0].name == 'import'

View File

@@ -1,7 +1,7 @@
import pytest import pytest
import jedi import jedi
from jedi._compatibility import py_version, unicode from jedi._compatibility import py_version
def _eval_literal(code): def _eval_literal(code):

View File

@@ -45,20 +45,5 @@ def generate_pyc():
shutil.copy(os.path.join("dummy_package/__pycache__", f), dst) shutil.copy(os.path.join("dummy_package/__pycache__", f), dst)
# Python 2.6 does not necessarily come with `compileall.compile_file`.
@pytest.mark.skipif("sys.version_info > (2,6)")
@cwd_at('test/test_evaluate')
def test_pyc():
"""
The list of completion must be greater than 2.
"""
try:
generate_pyc()
s = jedi.Script("from dummy_package import dummy; dummy.", path='blub.py')
assert len(s.completions()) >= 2
finally:
shutil.rmtree("dummy_package")
if __name__ == "__main__": if __name__ == "__main__":
test_pyc() test_pyc()

View File

@@ -6,7 +6,6 @@ from textwrap import dedent
import pytest import pytest
from jedi import Script from jedi import Script
from jedi._compatibility import is_py26
# The namedtuple is different for different Python2.7 versions. Some versions # The namedtuple is different for different Python2.7 versions. Some versions
# are missing the attribute `_class_template`. # are missing the attribute `_class_template`.
@@ -25,10 +24,7 @@ def test_namedtuple_str(letter, expected):
dave.%s""") % letter dave.%s""") % letter
result = Script(source).completions() result = Script(source).completions()
completions = set(r.name for r in result) completions = set(r.name for r in result)
if is_py26: assert completions == set(expected)
assert completions == set()
else:
assert completions == set(expected)
def test_namedtuple_list(): def test_namedtuple_list():
@@ -39,10 +35,7 @@ def test_namedtuple_list():
garfield.l""") garfield.l""")
result = Script(source).completions() result = Script(source).completions()
completions = set(r.name for r in result) completions = set(r.name for r in result)
if is_py26: assert completions == set(['legs', 'length', 'large'])
assert completions == set()
else:
assert completions == set(['legs', 'length', 'large'])
def test_namedtuple_content(): def test_namedtuple_content():

View File

@@ -15,10 +15,6 @@ setenv =
PYTHONDONTWRITEBYTECODE=1 PYTHONDONTWRITEBYTECODE=1
commands = commands =
py.test {posargs:jedi test} py.test {posargs:jedi test}
[testenv:py26]
deps =
unittest2
{[testenv]deps}
[testenv:py27] [testenv:py27]
deps = deps =
# for testing the typing module # for testing the typing module