diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py index 1e456f16..595d530c 100644 --- a/jedi/_compatibility.py +++ b/jedi/_compatibility.py @@ -1,6 +1,6 @@ """ -To ensure compatibility from Python ``2.7`` - ``3.x``, a module has been -created. Clearly there is huge need to use conforming syntax. +This module is here to ensure compatibility of Windows/Linux/MacOS and +different Python versions. """ from __future__ import print_function import errno diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 1266bfd9..7c527128 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -94,7 +94,7 @@ class BaseName(object): @property def module_path(self): """ - Shows the file path of a module. e.g. ``/usr/lib/python2.7/os.py`` + Shows the file path of a module. e.g. ``/usr/lib/python3.9/os.py`` :rtype: str or None """ diff --git a/jedi/api/replstartup.py b/jedi/api/replstartup.py index 38aa8e6f..e0f23d19 100644 --- a/jedi/api/replstartup.py +++ b/jedi/api/replstartup.py @@ -9,7 +9,7 @@ just use IPython instead:: Then you will be able to use Jedi completer in your Python interpreter:: $ python - Python 2.7.2+ (default, Jul 20 2012, 22:15:08) + Python 3.9.2+ (default, Jul 20 2020, 22:15:08) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os diff --git a/jedi/inference/docstrings.py b/jedi/inference/docstrings.py index ab34cf93..27082124 100644 --- a/jedi/inference/docstrings.py +++ b/jedi/inference/docstrings.py @@ -201,11 +201,8 @@ def _infer_for_statement_string(module_context, string): # (e.g., 'threading' in 'threading.Thread'). string = 'import %s\n' % element + string - # Take the default grammar here, if we load the Python 2.7 grammar here, it - # will be impossible to use `...` (Ellipsis) as a token. Docstring types - # don't need to conform with the current grammar. debug.dbg('Parse docstring code %s', string, color='BLUE') - grammar = module_context.inference_state.latest_grammar + grammar = module_context.inference_state.grammar try: module = grammar.parse(code.format(indent_block(string)), error_recovery=False) except ParserSyntaxError: diff --git a/jedi/inference/star_args.py b/jedi/inference/star_args.py index 78ec8a0b..c7e28d6f 100644 --- a/jedi/inference/star_args.py +++ b/jedi/inference/star_args.py @@ -32,8 +32,6 @@ def _iter_nodes_for_param(param_name): argument = name.parent if argument.type == 'argument' \ and argument.children[0] == '*' * param_name.star_count: - # No support for Python 2.7 here, but they are end-of-life - # anyway trailer = search_ancestor(argument, 'trailer') if trailer is not None: # Make sure we're in a function context = execution_context.create_context(trailer) diff --git a/jedi/inference/syntax_tree.py b/jedi/inference/syntax_tree.py index 1734d150..af08a940 100644 --- a/jedi/inference/syntax_tree.py +++ b/jedi/inference/syntax_tree.py @@ -312,9 +312,6 @@ def infer_atom(context, atom): # For False/True/None if atom.value in ('False', 'True', 'None'): return ValueSet([compiled.builtin_from_name(state, atom.value)]) - elif atom.value == 'print': - # print e.g. could be inferred like this in Python 2.7 - return NO_VALUES elif atom.value == 'yield': # Contrary to yield from, yield can just appear alone to return a # value when used with `.send()`. diff --git a/test/helpers.py b/test/helpers.py index f2782829..e9426eba 100644 --- a/test/helpers.py +++ b/test/helpers.py @@ -3,15 +3,8 @@ A helper module for testing, improves compatibility for testing (as ``jedi._compatibility``) as well as introducing helper functions. """ -import sys from contextlib import contextmanager -if sys.hexversion < 0x02070000: - import unittest2 as unittest -else: - import unittest -TestCase = unittest.TestCase - import os import pytest from os.path import abspath, dirname, join diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index d880dc4c..cbf178a2 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -1,10 +1,10 @@ import sys from textwrap import dedent import inspect +from unittest import TestCase import pytest -from ..helpers import TestCase from jedi import cache from jedi.parser_utils import get_signature from jedi import Interpreter diff --git a/test/test_api/test_full_name.py b/test/test_api/test_full_name.py index 1822a493..242e0c1d 100644 --- a/test/test_api/test_full_name.py +++ b/test/test_api/test_full_name.py @@ -14,11 +14,11 @@ There are three kinds of test: """ import textwrap +from unittest import TestCase import pytest import jedi -from ..helpers import TestCase class MixinTestFullName(object): diff --git a/test/test_api/test_unicode.py b/test/test_api/test_unicode.py index 91090d1a..3ddb0c91 100644 --- a/test/test_api/test_unicode.py +++ b/test/test_api/test_unicode.py @@ -2,26 +2,25 @@ """ All character set and unicode related tests. """ -from jedi._compatibility import u, unicode +from jedi._compatibility import u from jedi import Project def test_unicode_script(Script): - """ normally no unicode objects are being used. (<=2.7) """ - s = unicode("import datetime; datetime.timedelta") + s = "import datetime; datetime.timedelta" completions = Script(s).complete() assert len(completions) - assert type(completions[0].description) is unicode + assert type(completions[0].description) is str s = u("author='öä'; author") completions = Script(s).complete() x = completions[0].description - assert type(x) is unicode + assert type(x) is str s = u("#-*- coding: iso-8859-1 -*-\nauthor='öä'; author") s = s.encode('latin-1') completions = Script(s).complete() - assert type(completions[0].description) is unicode + assert type(completions[0].description) is str def test_unicode_attribute(Script): diff --git a/test/test_parso_integration/test_basic.py b/test/test_parso_integration/test_basic.py index f2831dc5..cf174355 100644 --- a/test/test_parso_integration/test_basic.py +++ b/test/test_parso_integration/test_basic.py @@ -87,9 +87,6 @@ def test_tokenizer_with_string_literal_backslash(Script): def test_ellipsis_without_getitem(Script, environment): - if environment.version_info.major == 2: - pytest.skip('In 2.7 Ellipsis can only be used like x[...]') - def_, = Script('x=...;x').infer() assert def_.name == 'ellipsis' diff --git a/test/test_utils.py b/test/test_utils.py index 14ca802f..c37b3665 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -2,11 +2,10 @@ try: import readline except ImportError: readline = False +import unittest from jedi import utils -from .helpers import unittest - @unittest.skipIf(not readline, "readline not found") class TestSetupReadline(unittest.TestCase):