Replace Param.get_description with get_code and a parameter include_coma.

This commit is contained in:
Dave Halter
2017-05-01 02:19:42 +02:00
parent e0b0343a78
commit 63679aabd9
2 changed files with 16 additions and 5 deletions

View File

@@ -15,7 +15,7 @@ from jedi.evaluate import representation as er
from jedi.evaluate import instance from jedi.evaluate import instance
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi.evaluate import compiled from jedi.evaluate import compiled
from jedi.evaluate.filters import ParamName, TreeNameDefinition from jedi.evaluate.filters import ParamName
from jedi.evaluate.imports import ImportName from jedi.evaluate.imports import ImportName
from jedi.api.keywords import KeywordName from jedi.api.keywords import KeywordName
@@ -538,7 +538,12 @@ class Definition(BaseDefinition):
typ = 'def' typ = 'def'
return typ + ' ' + u(self._name.string_name) return typ + ' ' + u(self._name.string_name)
elif typ == 'param': elif typ == 'param':
return typ + ' ' + tree_name.get_definition().get_description() code = tree_name.get_definition().get_code(
include_prefix=False,
include_comma=False
)
return typ + ' ' + code
definition = tree_name.get_definition() definition = tree_name.get_definition()
# Remove the prefix, because that's not what we want for get_code # Remove the prefix, because that's not what we want for get_code

View File

@@ -983,12 +983,18 @@ class Param(PythonBaseNode):
""" """
return search_ancestor(self, ('funcdef', 'lambdef')) return search_ancestor(self, ('funcdef', 'lambdef'))
def get_description(self): def get_code(self, normalized=False, include_prefix=True, include_comma=True):
# TODO Remove? if include_comma:
return super(Param, self).get_code(normalized, include_prefix)
children = self.children children = self.children
if children[-1] == ',': if children[-1] == ',':
children = children[:-1] children = children[:-1]
return self._get_code_for_children(children, False, False) return self._get_code_for_children(
children,
normalized=False,
include_prefix=include_prefix
)
def __repr__(self): def __repr__(self):
default = '' if self.default is None else '=%s' % self.default.get_code() default = '' if self.default is None else '=%s' % self.default.get_code()