mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Remove the ClassVar filter, see also #1847
This commit is contained in:
@@ -120,21 +120,6 @@ class ClassFilter(ParserTreeFilter):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _access_possible(self, name):
|
def _access_possible(self, name):
|
||||||
# Filter for ClassVar variables
|
|
||||||
# TODO this is not properly done, yet. It just checks for the string
|
|
||||||
# ClassVar in the annotation, which can be quite imprecise. If we
|
|
||||||
# wanted to do this correct, we would have to infer the ClassVar.
|
|
||||||
if not self._is_instance:
|
|
||||||
expr_stmt = name.get_definition()
|
|
||||||
if expr_stmt is not None and expr_stmt.type == 'expr_stmt':
|
|
||||||
annassign = expr_stmt.children[1]
|
|
||||||
if annassign.type == 'annassign':
|
|
||||||
# If there is an =, the variable is obviously also
|
|
||||||
# defined on the class.
|
|
||||||
if 'ClassVar' not in annassign.children[1].get_code() \
|
|
||||||
and '=' not in annassign.children:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Filter for name mangling of private variables like __foo
|
# Filter for name mangling of private variables like __foo
|
||||||
return not name.value.startswith('__') or name.value.endswith('__') \
|
return not name.value.startswith('__') or name.value.endswith('__') \
|
||||||
or self._equals_origin_scope()
|
or self._equals_origin_scope()
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class Foo():
|
|||||||
baz: typing.ClassVar[str]
|
baz: typing.ClassVar[str]
|
||||||
|
|
||||||
|
|
||||||
#?
|
#? int()
|
||||||
Foo.bar
|
Foo.bar
|
||||||
#? int()
|
#? int()
|
||||||
Foo().bar
|
Foo().bar
|
||||||
@@ -81,11 +81,11 @@ class VarClass2(VarClass):
|
|||||||
#? int()
|
#? int()
|
||||||
self.var_class3
|
self.var_class3
|
||||||
|
|
||||||
#? ['var_class1', 'var_class2', 'var_instance1', 'var_class3']
|
#? ['var_class1', 'var_class2', 'var_instance1', 'var_class3', 'var_instance2']
|
||||||
VarClass.var_
|
VarClass.var_
|
||||||
#? int()
|
#? int()
|
||||||
VarClass.var_instance1
|
VarClass.var_instance1
|
||||||
#?
|
#? float()
|
||||||
VarClass.var_instance2
|
VarClass.var_instance2
|
||||||
#? str()
|
#? str()
|
||||||
VarClass.var_class1
|
VarClass.var_class1
|
||||||
|
|||||||
Reference in New Issue
Block a user