From a3afdc0ecea8ab754150c8e91023162c461ae536 Mon Sep 17 00:00:00 2001 From: Jean Cavallo Date: Wed, 12 Jun 2019 09:51:08 +0200 Subject: [PATCH 1/4] Ignore super calls when super class cannot be inferred --- jedi/plugins/stdlib.py | 3 +++ test/completion/stdlib.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index b0203f87..e578b5f5 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -243,6 +243,9 @@ def builtins_super(types, objects, context): if isinstance(context, FunctionExecutionContext): if isinstance(context.var_args, InstanceArguments): su = context.var_args.instance.py__class__().py__bases__() + # If super class cannot be infered + if len(su) == 0: + return NO_CONTEXTS return su[0].infer().execute_evaluated() return NO_CONTEXTS diff --git a/test/completion/stdlib.py b/test/completion/stdlib.py index 541e9024..7127efea 100644 --- a/test/completion/stdlib.py +++ b/test/completion/stdlib.py @@ -276,3 +276,17 @@ qsplit = shlex.split("foo, ferwerwerw werw werw e") for part in qsplit: #? str() part + +# ----------------- +# Unknown metaclass +# ----------------- + +# Github issue 1321 +class Meta(object): + pass + +class Test(metaclass=Meta): + def test_function(self): + result = super(Test, self).test_function() + #? [] + result. From ce97b0a5e74b83aa9910ebc8e14eb595fd4bdb80 Mon Sep 17 00:00:00 2001 From: Jean Cavallo Date: Thu, 13 Jun 2019 09:37:51 +0200 Subject: [PATCH 2/4] Make sure py__bases__always return something --- jedi/evaluate/context/klass.py | 18 ++++++++++-------- jedi/plugins/stdlib.py | 3 --- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/jedi/evaluate/context/klass.py b/jedi/evaluate/context/klass.py index 9c329d5d..acf68b67 100644 --- a/jedi/evaluate/context/klass.py +++ b/jedi/evaluate/context/klass.py @@ -233,14 +233,16 @@ class ClassContext(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBa if arglist: from jedi.evaluate import arguments args = arguments.TreeArguments(self.evaluator, self.parent_context, arglist) - return [value for key, value in args.unpack() if key is None] - else: - if self.py__name__() == 'object' \ - and self.parent_context == self.evaluator.builtins_module: - return [] - return [LazyKnownContexts( - self.evaluator.builtins_module.py__getattribute__('object') - )] + lst = [value for key, value in args.unpack() if key is None] + if lst: + return lst + + if self.py__name__() == 'object' \ + and self.parent_context == self.evaluator.builtins_module: + return [] + return [LazyKnownContexts( + self.evaluator.builtins_module.py__getattribute__('object') + )] def py__getitem__(self, index_context_set, contextualized_node): from jedi.evaluate.gradual.typing import LazyGenericClass diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index e578b5f5..b0203f87 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -243,9 +243,6 @@ def builtins_super(types, objects, context): if isinstance(context, FunctionExecutionContext): if isinstance(context.var_args, InstanceArguments): su = context.var_args.instance.py__class__().py__bases__() - # If super class cannot be infered - if len(su) == 0: - return NO_CONTEXTS return su[0].infer().execute_evaluated() return NO_CONTEXTS From c6c49d147600c1cf830d57d343df2bb71eb22a29 Mon Sep 17 00:00:00 2001 From: Trevor Sullivan Date: Wed, 12 Jun 2019 07:10:56 -0700 Subject: [PATCH 3/4] Update manual installation directions --- docs/docs/installation.rst | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/docs/docs/installation.rst b/docs/docs/installation.rst index 9058cf55..8499b94c 100644 --- a/docs/docs/installation.rst +++ b/docs/docs/installation.rst @@ -57,19 +57,14 @@ Others We are in the discussion of adding |jedi| to the Fedora repositories. -Manual installation from a downloaded package +Manual installation from GitHub --------------------------------------------- -If you prefer not to use an automated package installer, you can `download -`__ a current copy of -|jedi| and install it manually. - -To install it, navigate to the directory containing `setup.py` on your console -and type:: +If you prefer not to use an automated package installer, you can clone the source from GitHub and install it manually. To install it, run these commands:: + git clone --recurse-submodules sudo python setup.py install - Inclusion as a submodule ------------------------ From e7423696af8afe94773bb87ec5b1e1c1d8ee1e88 Mon Sep 17 00:00:00 2001 From: Trevor Sullivan Date: Thu, 13 Jun 2019 07:53:22 -0700 Subject: [PATCH 4/4] Added git URL to git clone command --- docs/docs/installation.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/installation.rst b/docs/docs/installation.rst index 8499b94c..1070a030 100644 --- a/docs/docs/installation.rst +++ b/docs/docs/installation.rst @@ -62,7 +62,8 @@ Manual installation from GitHub If you prefer not to use an automated package installer, you can clone the source from GitHub and install it manually. To install it, run these commands:: - git clone --recurse-submodules + git clone --recurse-submodules https://github.com/davidhalter/jedi + cd jedi sudo python setup.py install Inclusion as a submodule