mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
Drop support for EOL Python 2.6
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
language: python
|
||||
sudo: false
|
||||
python:
|
||||
- 2.6
|
||||
- 2.7
|
||||
- 3.3
|
||||
- 3.4
|
||||
|
||||
@@ -96,7 +96,7 @@ understands, see: `Features
|
||||
<https://jedi.readthedocs.org/en/latest/docs/features.html>`_. A list of
|
||||
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.
|
||||
|
||||
Tips on how to use Jedi efficiently can be found `here
|
||||
|
||||
@@ -20,7 +20,7 @@ make it work.
|
||||
General Features
|
||||
----------------
|
||||
|
||||
- python 2.6+ and 3.3+ support
|
||||
- Python 2.7 and 3.3+ support
|
||||
- ignores syntax errors and wrong indentation
|
||||
- can deal with complex module / function / class structures
|
||||
- virtualenv support
|
||||
@@ -64,7 +64,7 @@ Not yet implemented:
|
||||
|
||||
- manipulations of instances outside the instance variables without using
|
||||
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:
|
||||
|
||||
@@ -88,7 +88,7 @@ etc.
|
||||
**Security**
|
||||
|
||||
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
|
||||
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
|
||||
@@ -117,7 +117,7 @@ one of the following docstring/annotation syntax styles:
|
||||
|
||||
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)
|
||||
|
||||
::
|
||||
@@ -129,7 +129,7 @@ comments in planned but not yet implemented)
|
||||
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
|
||||
|
||||
::
|
||||
@@ -142,7 +142,7 @@ Note that the type hints must be on the same line as the statement
|
||||
print(f + 3)
|
||||
|
||||
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.
|
||||
|
||||
Things that are missing (and this is not an exhaustive list; some of these
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
import sys
|
||||
@@ -13,13 +13,10 @@ try:
|
||||
except ImportError:
|
||||
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_py33 = is_py3 and sys.version_info[1] >= 3
|
||||
is_py34 = is_py3 and sys.version_info[1] >= 4
|
||||
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]))
|
||||
|
||||
|
||||
@@ -127,14 +124,7 @@ def find_module_pre_py33(string, path=None, fullname=None):
|
||||
if loader:
|
||||
is_package = loader.is_package(string)
|
||||
is_archive = hasattr(loader, 'archive')
|
||||
try:
|
||||
module_path = loader.get_filename(string)
|
||||
except AttributeError:
|
||||
# fallback for py26
|
||||
try:
|
||||
module_path = loader._get_filename(string)
|
||||
except AttributeError:
|
||||
continue
|
||||
module_path = loader.get_filename(string)
|
||||
if is_package:
|
||||
module_path = os.path.dirname(module_path)
|
||||
if is_archive:
|
||||
@@ -242,11 +232,6 @@ import ast
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -256,13 +256,7 @@ def collections_namedtuple(evaluator, obj, arguments):
|
||||
This has to be done by processing the namedtuple class template and
|
||||
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
|
||||
# TODO here we only use one of the types, we should use all.
|
||||
name = list(_follow_param(evaluator, arguments, 0))[0].obj
|
||||
|
||||
1
setup.py
1
setup.py
@@ -44,7 +44,6 @@ setup(name='jedi',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.3',
|
||||
|
||||
@@ -403,8 +403,6 @@ def test_func():
|
||||
x
|
||||
|
||||
|
||||
# python >= 2.7
|
||||
# Set literals are not valid in 2.6.
|
||||
#? int()
|
||||
tuple({1})[0]
|
||||
|
||||
|
||||
@@ -286,8 +286,6 @@ with open('') as f:
|
||||
#? str()
|
||||
line
|
||||
|
||||
# Nested with statements don't exist in Python 2.6.
|
||||
# python >= 2.7
|
||||
with open('') as f1, open('') as f2:
|
||||
#? ['closed']
|
||||
f1.closed
|
||||
|
||||
@@ -210,6 +210,5 @@ d[2]
|
||||
next(iter({a for a in range(10)}))
|
||||
|
||||
|
||||
# with a set literal (also doesn't work in 2.6).
|
||||
#? int()
|
||||
[a for a in {1, 2, 3}][0]
|
||||
|
||||
@@ -288,8 +288,6 @@ third()[0]
|
||||
# -----------------
|
||||
# set.add
|
||||
# -----------------
|
||||
# Set literals are not valid in 2.6.
|
||||
# python >= 2.7
|
||||
st = {1.0}
|
||||
for a in [1,2]:
|
||||
st.add(a)
|
||||
|
||||
@@ -47,10 +47,6 @@ b
|
||||
class Employee:
|
||||
pass
|
||||
|
||||
# The typing library is not installable for Python 2.6, therefore ignore the
|
||||
# following tests.
|
||||
# python >= 2.7
|
||||
|
||||
from typing import List
|
||||
x = [] # type: List[Employee]
|
||||
#? Employee()
|
||||
|
||||
@@ -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
|
||||
still TODO at 2016-01-23)
|
||||
"""
|
||||
# There's no Python 2.6 typing module.
|
||||
# python >= 2.7
|
||||
import typing
|
||||
class B:
|
||||
pass
|
||||
|
||||
@@ -116,8 +116,6 @@ tup4.index
|
||||
# -----------------
|
||||
# set
|
||||
# -----------------
|
||||
# Set literals are not valid in 2.6.
|
||||
# python >= 2.7
|
||||
set_t = {1,2}
|
||||
|
||||
#? ['clear', 'copy']
|
||||
|
||||
@@ -296,8 +296,6 @@ x = 32
|
||||
[x for x in something]
|
||||
|
||||
x = 3
|
||||
# Not supported syntax in Python 2.6.
|
||||
# python >= 2.7
|
||||
#< 1 (0,1), (0,10)
|
||||
{x:1 for x in something}
|
||||
#< 10 (0,1), (0,10)
|
||||
|
||||
@@ -13,7 +13,6 @@ from jedi._compatibility import find_module_py33, find_module
|
||||
from ..helpers import cwd_at
|
||||
|
||||
from jedi import Script
|
||||
from jedi._compatibility import is_py26
|
||||
|
||||
|
||||
@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
|
||||
|
||||
|
||||
@pytest.mark.skipif('sys.version_info < (2,7)')
|
||||
def test_find_module_not_package_zipped():
|
||||
if 'zipped_imports/not_pkg.zip' not in sys.path:
|
||||
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'])
|
||||
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
|
||||
assert Script("from datetime import").completions()[0].name == 'import'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
import jedi
|
||||
from jedi._compatibility import py_version, unicode
|
||||
from jedi._compatibility import py_version
|
||||
|
||||
|
||||
def _eval_literal(code):
|
||||
|
||||
@@ -45,20 +45,5 @@ def generate_pyc():
|
||||
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__":
|
||||
test_pyc()
|
||||
|
||||
@@ -6,7 +6,6 @@ from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
from jedi import Script
|
||||
from jedi._compatibility import is_py26
|
||||
|
||||
# The namedtuple is different for different Python2.7 versions. Some versions
|
||||
# are missing the attribute `_class_template`.
|
||||
@@ -25,10 +24,7 @@ def test_namedtuple_str(letter, expected):
|
||||
dave.%s""") % letter
|
||||
result = Script(source).completions()
|
||||
completions = set(r.name for r in result)
|
||||
if is_py26:
|
||||
assert completions == set()
|
||||
else:
|
||||
assert completions == set(expected)
|
||||
assert completions == set(expected)
|
||||
|
||||
|
||||
def test_namedtuple_list():
|
||||
@@ -39,10 +35,7 @@ def test_namedtuple_list():
|
||||
garfield.l""")
|
||||
result = Script(source).completions()
|
||||
completions = set(r.name for r in result)
|
||||
if is_py26:
|
||||
assert completions == set()
|
||||
else:
|
||||
assert completions == set(['legs', 'length', 'large'])
|
||||
assert completions == set(['legs', 'length', 'large'])
|
||||
|
||||
|
||||
def test_namedtuple_content():
|
||||
|
||||
Reference in New Issue
Block a user