forked from VimPlug/jedi
Fix the compatibility docstring
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()`.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user