Remove the deprecated attributes from Jedi.

This commit is contained in:
Dave Halter
2017-09-20 18:27:29 +02:00
parent 0c01a3b823
commit d6a04b2928
4 changed files with 6 additions and 113 deletions

View File

@@ -38,6 +38,6 @@ good text editor, while still having very good IDE features for Python.
__version__ = '0.11.0'
from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
from jedi.api import preload_module, defined_names, names
from jedi.api import Script, Interpreter, set_debug_function
from jedi.api import preload_module, names
from jedi import settings

View File

@@ -10,7 +10,6 @@ arguments.
.. warning:: Please, note that Jedi is **not thread safe**.
"""
import os
import warnings
import sys
import parso
@@ -40,16 +39,6 @@ from jedi.evaluate.filters import TreeNameDefinition
sys.setrecursionlimit(3000)
class NotFoundError(Exception):
"""A custom error to avoid catching the wrong exceptions.
.. deprecated:: 0.9.0
Not in use anymore, Jedi just returns no goto result if you're not on a
valid name.
.. todo:: Remove!
"""
class Script(object):
"""
A Script is the base for completions, goto or whatever you want to do with
@@ -90,15 +79,7 @@ class Script(object):
"""
def __init__(self, source=None, line=None, column=None, path=None,
encoding='utf-8', source_path=None, source_encoding=None,
sys_path=None):
if source_path is not None:
warnings.warn("Deprecated since version 0.7. Use path instead of source_path.", DeprecationWarning, stacklevel=2)
path = source_path
if source_encoding is not None:
warnings.warn("Deprecated since version 0.8. Use encoding instead of source_encoding.", DeprecationWarning, stacklevel=2)
encoding = source_encoding
encoding='utf-8', sys_path=None):
self._orig_path = path
# An empty path (also empty string) should always result in no path.
self.path = os.path.abspath(path) if path else None
@@ -157,16 +138,6 @@ class Script(object):
imports.add_module(self._evaluator, name, module)
return module
@property
def source_path(self):
"""
.. deprecated:: 0.7.0
Use :attr:`.path` instead.
.. todo:: Remove!
"""
warnings.warn("Deprecated since version 0.7. Use path instead of source_path.", DeprecationWarning, stacklevel=2)
return self.path
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, repr(self._orig_path))
@@ -425,26 +396,6 @@ class Interpreter(Script):
)
def defined_names(source, path=None, encoding='utf-8'):
"""
Get all definitions in `source` sorted by its position.
This functions can be used for listing functions, classes and
data defined in a file. This can be useful if you want to list
them in "sidebar". Each element in the returned list also has
`defined_names` method which can be used to get sub-definitions
(e.g., methods in class).
:rtype: list of classes.Definition
.. deprecated:: 0.9.0
Use :func:`names` instead.
.. todo:: Remove!
"""
warnings.warn("Use names instead.", DeprecationWarning)
return names(source, path, encoding)
def names(source=None, path=None, encoding='utf-8', all_scopes=False,
definitions=True, references=False):
"""

View File

@@ -3,7 +3,6 @@ The :mod:`jedi.api.classes` module contains the return classes of the API.
These classes are the much bigger part of the whole API, because they contain
the interesting information about completion and goto operations.
"""
import warnings
import re
from parso.cache import parser_cache
@@ -257,26 +256,6 @@ class BaseDefinition(object):
"""
return _Help(self._name).docstring(fast=fast, raw=raw)
@property
def doc(self):
"""
.. deprecated:: 0.8.0
Use :meth:`.docstring` instead.
.. todo:: Remove!
"""
warnings.warn("Deprecated since Jedi 0.8. Use docstring() instead.", DeprecationWarning, stacklevel=2)
return self.docstring(raw=False)
@property
def raw_doc(self):
"""
.. deprecated:: 0.8.0
Use :meth:`.docstring` instead.
.. todo:: Remove!
"""
warnings.warn("Deprecated since Jedi 0.8. Use docstring() instead.", DeprecationWarning, stacklevel=2)
return self.docstring(raw=True)
@property
def description(self):
"""A textual description of the object."""
@@ -368,7 +347,7 @@ class BaseDefinition(object):
raise AttributeError()
context = followed[0] # only check the first one.
return [_Param(self._evaluator, n) for n in get_param_names(context)]
return [Definition(self._evaluator, n) for n in get_param_names(context)]
def parent(self):
context = self._name.parent_context
@@ -662,48 +641,11 @@ class CallSignature(Definition):
"""
return self._bracket_start_pos
@property
def call_name(self):
"""
.. deprecated:: 0.8.0
Use :attr:`.name` instead.
.. todo:: Remove!
The name (e.g. 'isinstance') as a string.
"""
warnings.warn("Deprecated since Jedi 0.8. Use name instead.", DeprecationWarning, stacklevel=2)
return self.name
@property
def module(self):
"""
.. deprecated:: 0.8.0
Use :attr:`.module_name` for the module name.
.. todo:: Remove!
"""
return self._executable.get_root_node()
def __repr__(self):
return '<%s: %s index %s>' % \
(type(self).__name__, self._name.string_name, self.index)
class _Param(Definition):
"""
Just here for backwards compatibility.
"""
def get_code(self):
"""
.. deprecated:: 0.8.0
Use :attr:`.description` and :attr:`.name` instead.
.. todo:: Remove!
A function to get the whole code of the param.
"""
warnings.warn("Deprecated since version 0.8. Use description instead.", DeprecationWarning, stacklevel=2)
return self.description
class _Help(object):
"""
Temporary implementation, will be used as `Script.help() or something in

View File

@@ -6,7 +6,7 @@ from inspect import cleandoc
import pytest
from jedi import Script, defined_names, __doc__ as jedi_doc, names
from jedi import Script, __doc__ as jedi_doc, names
from ..helpers import cwd_at
from ..helpers import TestCase
@@ -42,7 +42,7 @@ def make_definitions():
""")
definitions = []
definitions += defined_names(source)
definitions += names(source)
source += dedent("""
variable = sys or C or x or f or g or g() or h""")