Always cast pr to er in _follow_statements_imports

This commit is contained in:
Fredrik Bergroth
2014-06-11 23:28:40 +02:00
parent 41f32f21ea
commit d3ac1e902e
3 changed files with 12 additions and 5 deletions

View File

@@ -23,5 +23,6 @@ srusskih (@srusskih)
Steven Silvester (@blink1073)
Colin Duquesnoy (@ColinDuquesnoy) <colin.duquesnoy@gmail.com>
Jorgen Schaefer (@jorgenschaefer) <contact@jorgenschaefer.de>
Fredrik Bergroth (@fbergroth)
Note: (@user) means a github user name.

View File

@@ -307,11 +307,12 @@ class BaseDefinition(object):
stripped = self._definition
if isinstance(stripped, pr.Name):
stripped = stripped.parent
# We should probably work in `Finder._names_to_types` here.
if isinstance(stripped, pr.Function):
stripped = er.Function(self._evaluator, stripped)
elif isinstance(stripped, pr.Class):
stripped = er.Class(self._evaluator, stripped)
# We should probably work in `Finder._names_to_types` here.
if isinstance(stripped, pr.Function):
stripped = er.Function(self._evaluator, stripped)
elif isinstance(stripped, pr.Class):
stripped = er.Class(self._evaluator, stripped)
if stripped.isinstance(pr.Statement):
return self._evaluator.eval_statement(stripped)

View File

@@ -127,6 +127,11 @@ def test_completion_docstring():
assert c.docstring(raw=True, fast=False) == cleandoc(Script.__doc__)
def test_completion_params():
c = Script('import string; string.capwords').completions()[0]
assert [p.name for p in c.params] == ['s', 'sep']
def test_signature_params():
def check(defs):
params = defs[0].params