mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 23:09:43 +08:00
if both docstring and annotations are present, use both for function parameters
This commit is contained in:
@@ -388,15 +388,11 @@ def _eval_param(evaluator, param, scope):
|
|||||||
and func.instance.is_generated and str(func.name) == '__init__':
|
and func.instance.is_generated and str(func.name) == '__init__':
|
||||||
param = func.var.params[param.position_nr]
|
param = func.var.params[param.position_nr]
|
||||||
|
|
||||||
# Add pep0484 type hints
|
# Add pep0484 and docstring knowledge.
|
||||||
pep0484_hints = pep0484.follow_param(evaluator, param)
|
pep0484_hints = pep0484.follow_param(evaluator, param)
|
||||||
if pep0484_hints:
|
|
||||||
return pep0484_hints
|
|
||||||
|
|
||||||
# Add docstring knowledge.
|
|
||||||
doc_params = docstrings.follow_param(evaluator, param)
|
doc_params = docstrings.follow_param(evaluator, param)
|
||||||
if doc_params:
|
if pep0484_hints or doc_params:
|
||||||
return doc_params
|
return list(set(pep0484_hints) | set(doc_params))
|
||||||
|
|
||||||
if isinstance(param, ExecutedParam):
|
if isinstance(param, ExecutedParam):
|
||||||
return res_new | param.eval(evaluator)
|
return res_new | param.eval(evaluator)
|
||||||
|
|||||||
@@ -7,7 +7,13 @@ class A():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def function_parameters(a: A, b, c: str, d: int=4):
|
def function_parameters(a: A, b, c: str, d: int, e: str, f: str, g: int=4):
|
||||||
|
"""
|
||||||
|
:param e: if docstring and annotation agree, only one should be returned
|
||||||
|
:type e: str
|
||||||
|
:param f: if docstring and annotation disagree, both should be returned
|
||||||
|
:type f: int
|
||||||
|
"""
|
||||||
#? A()
|
#? A()
|
||||||
a
|
a
|
||||||
#?
|
#?
|
||||||
@@ -16,6 +22,12 @@ def function_parameters(a: A, b, c: str, d: int=4):
|
|||||||
c
|
c
|
||||||
#? int()
|
#? int()
|
||||||
d
|
d
|
||||||
|
#? str()
|
||||||
|
e
|
||||||
|
#? int() str()
|
||||||
|
f
|
||||||
|
# int()
|
||||||
|
g
|
||||||
|
|
||||||
|
|
||||||
def return_unspecified():
|
def return_unspecified():
|
||||||
|
|||||||
Reference in New Issue
Block a user