forked from VimPlug/jedi
A irst super() implementation in stdlib.
This commit is contained in:
@@ -67,7 +67,7 @@ def argument_clinic(string, want_obj=False):
|
|||||||
# at the end of the arguments. This is therefore not a proper argument
|
# at the end of the arguments. This is therefore not a proper argument
|
||||||
# clinic implementation. `range()` for exmple allows an optional start
|
# clinic implementation. `range()` for exmple allows an optional start
|
||||||
# value at the beginning.
|
# value at the beginning.
|
||||||
match = re.match('(?:(?:(\[), ?|, ?|)(\w+)|, ?/)\]*', string)
|
match = re.match('(?:(?:(\[),? ?|, ?|)(\w+)|, ?/)\]*', string)
|
||||||
string = string[len(match.group(0)):]
|
string = string[len(match.group(0)):]
|
||||||
if not match.group(2): # A slash -> allow named arguments
|
if not match.group(2): # A slash -> allow named arguments
|
||||||
allow_kwargs = True
|
allow_kwargs = True
|
||||||
@@ -82,6 +82,9 @@ def argument_clinic(string, want_obj=False):
|
|||||||
lst = list(arguments.eval_argument_clinic(clinic_args))
|
lst = list(arguments.eval_argument_clinic(clinic_args))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return []
|
return []
|
||||||
|
else:
|
||||||
|
if want_obj:
|
||||||
|
return func(evaluator, obj, *lst)
|
||||||
else:
|
else:
|
||||||
return func(evaluator, *lst)
|
return func(evaluator, *lst)
|
||||||
|
|
||||||
@@ -124,10 +127,11 @@ class SuperInstance(er.Instance):
|
|||||||
super().__init__(evaluator, su and su[0] or self)
|
super().__init__(evaluator, su and su[0] or self)
|
||||||
|
|
||||||
|
|
||||||
def builtins_super(evaluator, obj, params):
|
@argument_clinic('[type[, obj]], /', want_obj=True)
|
||||||
|
def builtins_super(evaluator, obj, types, objects):
|
||||||
# TODO make this able to detect multiple inheritance super
|
# TODO make this able to detect multiple inheritance super
|
||||||
accept = (pr.Function, er.FunctionExecution)
|
accept = (pr.Function, er.FunctionExecution)
|
||||||
func = params.get_parent_until(accept)
|
func = obj.get_parent_until(accept)
|
||||||
if func.isinstance(*accept):
|
if func.isinstance(*accept):
|
||||||
wanted = (pr.Class, er.Instance)
|
wanted = (pr.Class, er.Instance)
|
||||||
cls = func.get_parent_until(accept + wanted,
|
cls = func.get_parent_until(accept + wanted,
|
||||||
|
|||||||
Reference in New Issue
Block a user