if both docstring and annotations are present, use both for function parameters

This commit is contained in:
Claude
2015-12-13 23:55:07 +01:00
parent f8debace0d
commit 7f8b878c8c
2 changed files with 16 additions and 8 deletions

View File

@@ -388,15 +388,11 @@ def _eval_param(evaluator, param, scope):
and func.instance.is_generated and str(func.name) == '__init__':
param = func.var.params[param.position_nr]
# Add pep0484 type hints
# Add pep0484 and docstring knowledge.
pep0484_hints = pep0484.follow_param(evaluator, param)
if pep0484_hints:
return pep0484_hints
# Add docstring knowledge.
doc_params = docstrings.follow_param(evaluator, param)
if doc_params:
return doc_params
if pep0484_hints or doc_params:
return list(set(pep0484_hints) | set(doc_params))
if isinstance(param, ExecutedParam):
return res_new | param.eval(evaluator)

View File

@@ -7,7 +7,13 @@ class A():
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
#?
@@ -16,6 +22,12 @@ def function_parameters(a: A, b, c: str, d: int=4):
c
#? int()
d
#? str()
e
#? int() str()
f
# int()
g
def return_unspecified():