From abb2250bf5b11cd0b0733949311df54ca0adbbf1 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 20 Jul 2020 02:02:41 +0200 Subject: [PATCH 1/7] Remove all deprecations --- jedi/api/__init__.py | 99 +------------------------------------------- jedi/api/classes.py | 40 ------------------ 2 files changed, 1 insertion(+), 138 deletions(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 2be38b8f..3a9d5a68 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -8,7 +8,6 @@ debug messages to stdout, simply call :func:`set_debug_function` without arguments. """ import sys -import warnings from pathlib import Path import parso @@ -90,23 +89,16 @@ class Script(object): :param code: The source code of the current file, separated by newlines. :type code: str - :param line: Deprecated, please use it directly on e.g. ``.complete`` - :type line: int - :param column: Deprecated, please use it directly on e.g. ``.complete`` - :type column: int :param path: The path of the file in the file system, or ``''`` if it hasn't been saved yet. :type path: str or pathlib.Path or None - :param sys_path: Deprecated, use the project parameter. - :type sys_path: typing.List[str] :param Environment environment: Provide a predefined :ref:`Environment ` to work with a specific Python version or virtualenv. :param Project project: Provide a :class:`.Project` to make sure finding references works well, because the right folder is searched. There are also ways to modify the sys path and other things. """ - def __init__(self, code=None, line=None, column=None, path=None, - sys_path=None, environment=None, project=None, source=None): + def __init__(self, code=None, *, path=None, environment=None, project=None): self._orig_path = path # An empty path (also empty string) should always result in no path. if isinstance(path, str): @@ -114,27 +106,6 @@ class Script(object): self.path = path.absolute() if path else None - if line is not None: - warnings.warn( - "Providing the line is now done in the functions themselves " - "like `Script(...).complete(line, column)`", - DeprecationWarning, - stacklevel=2 - ) - if column is not None: - warnings.warn( - "Providing the column is now done in the functions themselves " - "like `Script(...).complete(line, column)`", - DeprecationWarning, - stacklevel=2 - ) - if source is not None: - code = source - warnings.warn( - "Use the code keyword argument instead.", - DeprecationWarning, - stacklevel=2 - ) if code is None: # TODO add a better warning than the traceback! with open(path, 'rb') as f: @@ -143,15 +114,6 @@ class Script(object): if project is None: # Load the Python grammar of the current interpreter. project = get_default_project(None if self.path is None else self.path.parent) - # TODO deprecate and remove sys_path from the Script API. - if sys_path is not None: - project._sys_path = sys_path - warnings.warn( - "Deprecated since version 0.17.0. Use the project API instead, " - "which means Script(project=Project(dir, sys_path=sys_path)) instead.", - DeprecationWarning, - stacklevel=2 - ) self._inference_state = InferenceState( project, environment=environment, script_path=self.path @@ -168,7 +130,6 @@ class Script(object): debug.speed('parsed') self._code_lines = parso.split_lines(code, keepends=True) self._code = code - self._pos = line, column cache.clear_time_caches() debug.reset_time() @@ -250,14 +211,6 @@ class Script(object): ) return completion.complete() - def completions(self, fuzzy=False): - warnings.warn( - "Deprecated since version 0.16.0. Use Script(...).complete instead.", - DeprecationWarning, - stacklevel=2 - ) - return self.complete(*self._pos, fuzzy=fuzzy) - @validate_line_column def infer(self, line=None, column=None, *, only_stubs=False, prefer_stubs=False): """ @@ -297,25 +250,6 @@ class Script(object): # the API. return helpers.sorted_definitions(set(defs)) - def goto_definitions(self, **kwargs): - warnings.warn( - "Deprecated since version 0.16.0. Use Script(...).infer instead.", - DeprecationWarning, - stacklevel=2 - ) - return self.infer(*self._pos, **kwargs) - - def goto_assignments(self, follow_imports=False, follow_builtin_imports=False, **kwargs): - warnings.warn( - "Deprecated since version 0.16.0. Use Script(...).goto instead.", - DeprecationWarning, - stacklevel=2 - ) - return self.goto(*self._pos, - follow_imports=follow_imports, - follow_builtin_imports=follow_builtin_imports, - **kwargs) - @validate_line_column def goto(self, line=None, column=None, *, follow_imports=False, follow_builtin_imports=False, only_stubs=False, prefer_stubs=False): @@ -446,14 +380,6 @@ class Script(object): return [classes.Name(self._inference_state, name)] return [] - def usages(self, **kwargs): - warnings.warn( - "Deprecated since version 0.16.0. Use Script(...).get_references instead.", - DeprecationWarning, - stacklevel=2 - ) - return self.get_references(*self._pos, **kwargs) - @validate_line_column def get_references(self, line=None, column=None, **kwargs): """ @@ -484,14 +410,6 @@ class Script(object): return helpers.sorted_definitions(definitions) return _references(**kwargs) - def call_signatures(self): - warnings.warn( - "Deprecated since version 0.16.0. Use Script(...).get_signatures instead.", - DeprecationWarning, - stacklevel=2 - ) - return self.get_signatures(*self._pos) - @validate_line_column def get_signatures(self, line=None, column=None): """ @@ -817,21 +735,6 @@ class Interpreter(Script): ) -def names(source=None, path=None, all_scopes=False, - definitions=True, references=False, environment=None): - warnings.warn( - "Deprecated since version 0.16.0. Use Script(...).get_names instead.", - DeprecationWarning, - stacklevel=2 - ) - - return Script(source, path=path).get_names( - all_scopes=all_scopes, - definitions=definitions, - references=references, - ) - - def preload_module(*modules): """ Preloading modules tells Jedi to load a module now, instead of lazy parsing diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 679d1e59..cadff7b1 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -14,7 +14,6 @@ These classes are the much biggest part of the API, because they contain the interesting information about all operations. """ import re -import warnings from typing import Optional from parso.python.tree import search_ancestor @@ -453,14 +452,6 @@ class BaseName(object): return [self if n == self._name else Name(self._inference_state, n) for n in names] - def goto_assignments(self, **kwargs): - warnings.warn( - "Deprecated since version 0.16.0. Use .goto.", - DeprecationWarning, - stacklevel=2 - ) - return self.goto(**kwargs) - @debug.increase_indent_cm('infer on name') def infer(self, *, only_stubs=False, prefer_stubs=False): """ @@ -497,28 +488,6 @@ class BaseName(object): return [self if n == self._name else Name(self._inference_state, n) for n in resulting_names] - @property - @memoize_method - def params(self): - warnings.warn( - "Deprecated since version 0.16.0. Use get_signatures()[...].params", - DeprecationWarning, - stacklevel=2 - ) - # Only return the first one. There might be multiple one, especially - # with overloading. - for signature in self._get_signatures(): - return [ - Name(self._inference_state, n) - for n in signature.get_param_names(resolve_stars=True) - ] - - if self.type == 'function' or self.type == 'class': - # Fallback, if no signatures were defined (which is probably by - # itself a bug). - return [] - raise AttributeError('There are no params defined on this.') - def parent(self): """ Returns the parent scope of this identifier. @@ -763,15 +732,6 @@ class Name(BaseName): def __init__(self, inference_state, definition): super().__init__(inference_state, definition) - @property - def desc_with_module(self): - warnings.warn( - "Deprecated since version 0.17.0. No replacement for now, maybe .full_name helps", - DeprecationWarning, - stacklevel=2 - ) - return "%s:%s" % (self.module_name, self.description) - @memoize_method def defined_names(self): """ From d7d42c8e39f7d4e0da73d22b0bbf0fb34f43c5ad Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 20 Jul 2020 02:04:31 +0200 Subject: [PATCH 2/7] Rewrite the deprecation handling --- docs/docs/api.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/docs/api.rst b/docs/docs/api.rst index 33346d7d..8eac9bd6 100644 --- a/docs/docs/api.rst +++ b/docs/docs/api.rst @@ -169,6 +169,5 @@ Deprecations The deprecation process is as follows: -1. A deprecation is announced in the next major/minor release. -2. We wait either at least a year and at least two minor releases until we - remove the deprecated functionality. +1. A deprecation is announced in any release. +2. The next major release removes the deprecated functionality. From 89f525407afdd6005ae03a02834f514951fb9a7a Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 20 Jul 2020 02:06:17 +0200 Subject: [PATCH 3/7] Remove the deprecation tests --- jedi/__init__.py | 3 +-- test/test_deprecation.py | 39 --------------------------------------- 2 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 test/test_deprecation.py diff --git a/jedi/__init__.py b/jedi/__init__.py index b7641918..1c8cb682 100644 --- a/jedi/__init__.py +++ b/jedi/__init__.py @@ -29,8 +29,7 @@ load __version__ = '0.17.2' -from jedi.api import Script, Interpreter, set_debug_function, \ - preload_module, names +from jedi.api import Script, Interpreter, set_debug_function, preload_module from jedi import settings from jedi.api.environment import find_virtualenvs, find_system_environments, \ get_default_environment, InvalidPythonEnvironment, create_environment, \ diff --git a/test/test_deprecation.py b/test/test_deprecation.py deleted file mode 100644 index 39e2baa9..00000000 --- a/test/test_deprecation.py +++ /dev/null @@ -1,39 +0,0 @@ -import warnings - -import pytest - - -@pytest.fixture(autouse=True) -def check_for_warning(recwarn): - warnings.simplefilter("always") - with pytest.warns(DeprecationWarning): - yield - - -def test_goto_definitions(Script): - int_, = Script('x = 1\nx, y\ny', line=2, column=0).goto_definitions() - assert int_.name == 'int' - - -def test_completions(Script): - c1, c2 = Script('foobar = 1\nfoobaz= 2\nfoobaz, ffff\nfool = 3', line=3, column=3).completions() - assert c1.name == 'foobar' - assert c2.name == 'foobaz' - - -def test_goto_assignments(Script): - int_, = Script('x = 1\nx, y\ny', line=2, column=0).goto_assignments() - assert int_.get_line_code() == 'x = 1\n' - - -def test_usages(Script): - d1, d2 = Script('x = 1\nx, y\ny', line=2, column=0).usages() - assert d1.name == 'x' - assert d1.line == 1 - assert d2.name == 'x' - assert d2.line == 2 - - -def test_call_signatures(Script): - d1, = Script('abs(float(\nstr(', line=1, column=4).call_signatures() - assert d1.name == 'abs' From 1e633ab8edab9ce6fec2a84a3566faabfbdcb804 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 20 Jul 2020 02:19:37 +0200 Subject: [PATCH 4/7] Remove the requirements file, it should not be necessary --- MANIFEST.in | 1 - requirements.txt | 1 - setup.py | 4 +--- 3 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 requirements.txt diff --git a/MANIFEST.in b/MANIFEST.in index d6387b17..75a895c6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,7 +6,6 @@ include .coveragerc include sith.py include conftest.py include pytest.ini -include requirements.txt recursive-include jedi/third_party *.pyi include jedi/third_party/typeshed/LICENSE include jedi/third_party/django-stubs/LICENSE.txt diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index eb169cbe..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -parso>=0.7.0,<0.8.0 diff --git a/setup.py b/setup.py index 044d7d5a..33e24614 100755 --- a/setup.py +++ b/setup.py @@ -12,8 +12,6 @@ __AUTHOR_EMAIL__ = 'davidhalter88@gmail.com' version = get_module_constant("jedi", "__version__") readme = open('README.rst').read() + '\n\n' + open('CHANGELOG.rst').read() -with open('requirements.txt') as f: - install_requires = f.read().splitlines() assert os.path.isfile("jedi/third_party/typeshed/LICENSE"), \ "Please download the typeshed submodule first (Hint: git submodule update --init)" @@ -34,7 +32,7 @@ setup(name='jedi', long_description=readme, packages=find_packages(exclude=['test', 'test.*']), python_requires='>=3.6', - install_requires=install_requires, + install_requires=['parso>=0.7.0,<0.8.0'], extras_require={ 'testing': [ 'pytest<6.0.0', From bb303a75c0a5b23f23e0e929c0029ae905b23d26 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 20 Jul 2020 23:58:46 +0200 Subject: [PATCH 5/7] Fix a test --- test/test_api/test_call_signatures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_api/test_call_signatures.py b/test/test_api/test_call_signatures.py index 59e3a640..473edc9d 100644 --- a/test/test_api/test_call_signatures.py +++ b/test/test_api/test_call_signatures.py @@ -256,7 +256,7 @@ def test_complex(Script, environment): def _params(Script, source, line=None, column=None): - signatures = Script(source, line, column).get_signatures() + signatures = Script(source).get_signatures(line, column) assert len(signatures) == 1 return signatures[0].params From 1b16ca0e2ecb1c34a558b6948b4630bff1006f89 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 12 Dec 2020 12:25:22 +0100 Subject: [PATCH 6/7] Add sith.py to the files to be ignored by pytest --- conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/conftest.py b/conftest.py index f174c1e8..c6d02216 100644 --- a/conftest.py +++ b/conftest.py @@ -16,6 +16,7 @@ collect_ignore = [ 'jedi/inference/compiled/subprocess/__main__.py', 'build/', 'test/examples', + 'sith.py', ] From fa2d03a4fb97c3f8348f951655164e372e6a78fe Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 12 Dec 2020 12:31:44 +0100 Subject: [PATCH 7/7] Mention removal of deprecations in CHANGELOG --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f288f8f4..cb63a27a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,7 @@ Unreleased - Started using annotations - Better support for the walrus operator - Project attributes are now read accessible +- Removed all deprecations This is likely going to be the last minor release before 1.0.