forked from VimPlug/jedi
TypedDict checking should be at a later point
This commit is contained in:
@@ -350,33 +350,6 @@ class TypedDictBase(BaseTypingValue):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TypedDictClass(Value):
|
|
||||||
"""
|
|
||||||
This represents a class defined like:
|
|
||||||
|
|
||||||
class Foo(TypedDict):
|
|
||||||
bar: str
|
|
||||||
"""
|
|
||||||
def __init__(self, definition_class):
|
|
||||||
super().__init__(definition_class.inference_state, definition_class.parent_context)
|
|
||||||
self.tree_node = definition_class.tree_node
|
|
||||||
self._definition_class = definition_class
|
|
||||||
|
|
||||||
def get_filters(self, origin_scope=None):
|
|
||||||
"""
|
|
||||||
A TypedDict doesn't have attributes.
|
|
||||||
"""
|
|
||||||
o, = self.inference_state.builtins_module.py__getattribute__('object')
|
|
||||||
return o.get_filters()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
return ValueName(self, self.tree_node.name)
|
|
||||||
|
|
||||||
def py__call__(self, arguments):
|
|
||||||
return ValueSet({TypedDict(self._definition_class)})
|
|
||||||
|
|
||||||
|
|
||||||
class TypedDict(LazyValueWrapper):
|
class TypedDict(LazyValueWrapper):
|
||||||
"""Represents the instance version of ``TypedDictClass``."""
|
"""Represents the instance version of ``TypedDictClass``."""
|
||||||
def __init__(self, definition_class):
|
def __init__(self, definition_class):
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ from jedi.inference.compiled.access import COMPARISON_OPERATORS
|
|||||||
from jedi.inference.cache import inference_state_method_cache
|
from jedi.inference.cache import inference_state_method_cache
|
||||||
from jedi.inference.gradual.stub_value import VersionInfo
|
from jedi.inference.gradual.stub_value import VersionInfo
|
||||||
from jedi.inference.gradual import annotation
|
from jedi.inference.gradual import annotation
|
||||||
from jedi.inference.gradual.typing import TypedDictClass
|
|
||||||
from jedi.inference.names import TreeNameDefinition
|
from jedi.inference.names import TreeNameDefinition
|
||||||
from jedi.inference.context import CompForContext
|
from jedi.inference.context import CompForContext
|
||||||
from jedi.inference.value.decorator import Decoratee
|
from jedi.inference.value.decorator import Decoratee
|
||||||
@@ -749,8 +748,6 @@ def _apply_decorators(context, node):
|
|||||||
parent_context=context,
|
parent_context=context,
|
||||||
tree_node=node
|
tree_node=node
|
||||||
)
|
)
|
||||||
if decoratee_value.is_typeddict():
|
|
||||||
decoratee_value = TypedDictClass(decoratee_value)
|
|
||||||
else:
|
else:
|
||||||
decoratee_value = FunctionValue.from_context(context, node)
|
decoratee_value = FunctionValue.from_context(context, node)
|
||||||
initial = values = ValueSet([decoratee_value])
|
initial = values = ValueSet([decoratee_value])
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class ClassMixin(object):
|
|||||||
|
|
||||||
def py__call__(self, arguments=None):
|
def py__call__(self, arguments=None):
|
||||||
from jedi.inference.value import TreeInstance
|
from jedi.inference.value import TreeInstance
|
||||||
|
|
||||||
|
from jedi.inference.gradual.typing import TypedDict
|
||||||
|
if self.is_typeddict():
|
||||||
|
return ValueSet([TypedDict(self)])
|
||||||
return ValueSet([TreeInstance(self.inference_state, self.parent_context, self, arguments)])
|
return ValueSet([TreeInstance(self.inference_state, self.parent_context, self, arguments)])
|
||||||
|
|
||||||
def py__class__(self):
|
def py__class__(self):
|
||||||
|
|||||||
@@ -558,6 +558,8 @@ d.foo
|
|||||||
Foo.set
|
Foo.set
|
||||||
#? ['setdefault']
|
#? ['setdefault']
|
||||||
d.setdefaul
|
d.setdefaul
|
||||||
|
#? []
|
||||||
|
Foo.setdefaul
|
||||||
|
|
||||||
#? 5 ["'foo"]
|
#? 5 ["'foo"]
|
||||||
d['fo']
|
d['fo']
|
||||||
|
|||||||
Reference in New Issue
Block a user