From 4fecca032d125a1d4160e09b12f9aa7f4a471bc7 Mon Sep 17 00:00:00 2001 From: tamago324 Date: Mon, 25 Feb 2019 22:14:21 +0900 Subject: [PATCH 1/4] Fix typo --- jedi/api/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jedi/api/__init__.py b/jedi/api/__init__.py index 9e568cf8..7801dcf2 100644 --- a/jedi/api/__init__.py +++ b/jedi/api/__init__.py @@ -78,7 +78,7 @@ class Script(object): :param sys_path: ``sys.path`` to use during analysis of the script :type sys_path: list :param environment: TODO - :type sys_path: Environment + :type environment: Environment """ def __init__(self, source=None, line=None, column=None, path=None, encoding='utf-8', sys_path=None, environment=None): From 46742328b62185b524b0a363497ebc6ad121d4fe Mon Sep 17 00:00:00 2001 From: micbou Date: Fri, 1 Mar 2019 21:48:00 +0100 Subject: [PATCH 2/4] Improve test_import_completion_docstring robustness --- test/test_evaluate/test_imports.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_evaluate/test_imports.py b/test/test_evaluate/test_imports.py index ec349c01..d52882a3 100644 --- a/test/test_evaluate/test_imports.py +++ b/test/test_evaluate/test_imports.py @@ -132,13 +132,13 @@ def test_cache_works_with_sys_path_param(Script, tmpdir): def test_import_completion_docstring(Script): import abc s = Script('"""test"""\nimport ab') - completions = s.completions() - assert len(completions) == 1 - assert completions[0].docstring(fast=False) == abc.__doc__ + abc_completions = [c for c in s.completions() if c.name == 'abc'] + assert len(abc_completions) == 1 + assert abc_completions[0].docstring(fast=False) == abc.__doc__ # However for performance reasons not all modules are loaded and the # docstring is empty in this case. - assert completions[0].docstring() == '' + assert abc_completions[0].docstring() == '' def test_goto_definition_on_import(Script): From 6031971028314fa1f1cf41e22b9f9764c4093cb5 Mon Sep 17 00:00:00 2001 From: Stanislav Grozev Date: Fri, 31 Aug 2018 09:32:02 +0300 Subject: [PATCH 3/4] Use expanded paths when looking for virtualenv root This fixes virtualenv resolution under macOS and Pipenv. --- jedi/api/environment.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jedi/api/environment.py b/jedi/api/environment.py index a6616c5a..0d2b6729 100644 --- a/jedi/api/environment.py +++ b/jedi/api/environment.py @@ -154,7 +154,11 @@ def _get_virtual_env_from_var(): """ var = os.environ.get('VIRTUAL_ENV') if var: - if var == sys.prefix: + # Under macOS in some cases - notably when using Pipenv - the + # sys.prefix of the virtualenv is /path/to/env/bin/.. instead of + # /path/to/env so we need to fully resolve the paths in order to + # compare them. + if os.path.realpath(var) == os.path.realpath(sys.prefix): return _try_get_same_env() try: From f93134d4f8f888efa175e55dc4216e9739f6e0ba Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 8 Mar 2019 16:23:37 +0100 Subject: [PATCH 4/4] Two simple test fixes --- test/test_api/test_project.py | 2 +- test/test_evaluate/test_sys_path.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_api/test_project.py b/test/test_api/test_project.py index a0f4e4d5..328333d2 100644 --- a/test/test_api/test_project.py +++ b/test/test_api/test_project.py @@ -12,4 +12,4 @@ def test_django_default_project(Script): ) c, = script.completions() assert c.name == "SomeModel" - assert script._project._django is True + assert script._evaluator.project._django is True diff --git a/test/test_evaluate/test_sys_path.py b/test/test_evaluate/test_sys_path.py index a43e5262..8f1d8934 100644 --- a/test/test_evaluate/test_sys_path.py +++ b/test/test_evaluate/test_sys_path.py @@ -68,8 +68,8 @@ _s = ['/a', '/b', '/c/d/'] @pytest.mark.parametrize( 'sys_path_, module_path, result', [ - (_s, '/a/b', None), - (_s, '/a/b/c', None), + (_s, '/a/b', ['b']), + (_s, '/a/b/c', ['b', 'c']), (_s, '/a/b.py', ['b']), (_s, '/a/b/c.py', ['b', 'c']), (_s, '/x/b.py', None),