Revert some of the logic around ClassVar completions, see #1847

This commit is contained in:
Dave Halter
2022-11-12 23:14:56 +01:00
parent 8027e1b162
commit 26f7878d97
2 changed files with 0 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
from abc import abstractproperty
from parso.tree import search_ancestor
from parso.python.tree import Name
from jedi import debug
from jedi import settings
@@ -232,8 +231,6 @@ class _BaseTreeInstance(AbstractInstanceValue):
func_node = new
new = search_ancestor(new, 'funcdef', 'classdef')
if class_context.tree_node is new:
if isinstance(func_node, Name):
func_node = new
func = FunctionValue.from_context(class_context, func_node)
bound_method = BoundMethod(self, class_context, func)
if func_node.name.value == '__init__':
@@ -585,11 +582,6 @@ class SelfAttributeFilter(ClassFilter):
# filter.
if self._is_in_right_scope(trailer.parent.children[0], name):
yield name
elif trailer.type == "expr_stmt" \
and len(trailer.parent.children) == 2:
if name.is_definition() and self._access_possible(name):
if trailer.children[1].type == "annassign":
yield name
def _is_in_right_scope(self, self_name, name):
self_context = self._node_context.create_context(self_name)

View File

@@ -41,25 +41,6 @@ def test_in_empty_space(Script):
assert def_.name == 'X'
def test_classvar_completion(Script):
code = dedent('''\
from typing import ClassVar # 1
class Foo: # 2
var_class = None # 3
def __init__(self, var_class=None): # 4
self.var_class = var_class # 5
class Bar(Foo): # 6
var_class: ClassVar[int] # 7
def __init__(self): # 9
self.var_class.
int().
''')
actual_value = set(c.name for c in Script(code).complete(10, 23))
expected_value = set(c.name for c in Script(code).complete(11, 14))
assert expected_value == actual_value
def test_indent_value(Script):
"""
If an INDENT is the next supposed token, we should still be able to