diff --git a/jedi/evaluate/context/typing.py b/jedi/evaluate/context/typing.py index 0dc0ad73..a02992d2 100644 --- a/jedi/evaluate/context/typing.py +++ b/jedi/evaluate/context/typing.py @@ -166,7 +166,7 @@ class TypingContextWithIndex(_WithIndexBase): return ContextSet(self._index_context) elif string_name == 'ClassVar': # For now don't do anything here, ClassVars are always used. - return self._context.execute_annotation() + return self._index_context.execute_annotation() cls = globals()[string_name] return ContextSet(cls(self._name, self._index_context, self._context_of_index)) diff --git a/test/completion/pep0526_variables.py b/test/completion/pep0526_variables.py index ee848b6c..867fa54e 100644 --- a/test/completion/pep0526_variables.py +++ b/test/completion/pep0526_variables.py @@ -36,3 +36,18 @@ char: str for char in NOT_DEFINED: #? str() char + + +class Foo(): + bar: int + baz: typing.ClassVar[str] + + +#? int() +Foo.bar +#? int() +Foo().bar +#? str() +Foo.baz +#? str() +Foo().baz