From f5faca014f813bdc921f1d583571ad423968447b Mon Sep 17 00:00:00 2001 From: "Yusheng.Ma" Date: Wed, 17 Aug 2022 07:53:35 +0000 Subject: [PATCH] fix autocomplete crash in ycmd Signed-off-by: Yusheng.Ma --- jedi/inference/gradual/stub_value.py | 2 ++ jedi/inference/value/klass.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jedi/inference/gradual/stub_value.py b/jedi/inference/gradual/stub_value.py index c2e2bc4e..22f08a10 100644 --- a/jedi/inference/gradual/stub_value.py +++ b/jedi/inference/gradual/stub_value.py @@ -86,6 +86,8 @@ class StubFilter(ParserTreeFilter): # Imports in stub files are only public if they have an "as" # export. definition = name.get_definition() + if definition is None: + return False if definition.type in ('import_from', 'import_name'): if name.parent.type not in ('import_as_name', 'dotted_as_name'): return False diff --git a/jedi/inference/value/klass.py b/jedi/inference/value/klass.py index ee8d4e85..6ff1698c 100644 --- a/jedi/inference/value/klass.py +++ b/jedi/inference/value/klass.py @@ -78,6 +78,8 @@ class ClassName(TreeNameDefinition): type_ = super().api_type if type_ == 'function': definition = self.tree_name.get_definition() + if definition is None: + return type_ if function_is_property(definition): # This essentially checks if there is an @property before # the function. @property could be something different, but