forked from VimPlug/jedi
Dataclass progress
This commit is contained in:
@@ -520,6 +520,37 @@ def _random_choice(sequences):
|
||||
)
|
||||
|
||||
|
||||
def _dataclass(obj, arguments):
|
||||
for c in _follow_param(obj.evaluator, arguments, 0):
|
||||
if c.is_class():
|
||||
return ContextSet([DataclassWrapper(c)])
|
||||
else:
|
||||
return ContextSet([obj])
|
||||
return NO_CONTEXTS
|
||||
|
||||
|
||||
class DataclassWrapper(ContextWrapper):
|
||||
def get_signatures(self):
|
||||
params = []
|
||||
for cls in reversed(self._wrapped_context.py__mro__()):
|
||||
if isinstance(cls, ClassContext) and not cls.is_stub():
|
||||
filter_ = cls.get_global_filter()
|
||||
print(filter_)
|
||||
for name in filter_.values():
|
||||
d = name.tree_name.get_definition()
|
||||
if d.type == 'expr_stmt' and d.children[1].type == 'annassign':
|
||||
params.append()
|
||||
return [DataclassSignature(cls, params)]
|
||||
|
||||
|
||||
class DataclassSignature(AbstractSignature):
|
||||
def __init__(self, context, params):
|
||||
super(DataclassSignature, self).__init__(context)
|
||||
self._params = params
|
||||
|
||||
def get_param_names(self):
|
||||
|
||||
|
||||
class ItemGetterCallable(ContextWrapper):
|
||||
def __init__(self, instance, args_context_set):
|
||||
super(ItemGetterCallable, self).__init__(instance)
|
||||
@@ -602,7 +633,7 @@ _implemented = {
|
||||
},
|
||||
'dataclasses': {
|
||||
# For now this works at least better than Jedi trying to understand it.
|
||||
'dataclass': lambda obj, arguments: NO_CONTEXTS,
|
||||
'dataclass': _dataclass
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user