From 06699993f1efd8ced071f60a45ca91ad22d51983 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 4 Sep 2014 12:28:50 +0200 Subject: [PATCH] Class inheritance definitions shouldn't be params. It's just statements. --- jedi/evaluate/__init__.py | 1 - jedi/parser/__init__.py | 32 ++++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index bdb31566..55003f3c 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -324,7 +324,6 @@ class Evaluator(object): # statement name definitions. Only return, if it's one name and one # name only. Otherwise it's a mixture between a definition and a # reference. In this case it's just a definition. So we stay on it. - print stmt.get_defined_names() if len(call_path) == 1 and isinstance(call_path[0], pr.NamePart) \ and call_path[0] in [d.names[-1] for d in stmt.get_defined_names()]: return [call_path[0]] diff --git a/jedi/parser/__init__.py b/jedi/parser/__init__.py index 18460377..594a14ee 100644 --- a/jedi/parser/__init__.py +++ b/jedi/parser/__init__.py @@ -182,27 +182,31 @@ class Parser(object): :return: List of Statements :rtype: list """ - names = [] + params = [] tok = None pos = 0 breaks = [',', ':'] while tok is None or tok.string not in (')', ':'): + # Classes don't have params, a Class works more like a function + # call. param, tok = self._parse_statement(added_breaks=breaks, - stmt_class=pr.Param) - if param and tok.string == ':': - # parse annotations - annotation, tok = self._parse_statement(added_breaks=breaks) - if annotation: - param.add_annotation(annotation) + stmt_class=pr.Statement + if is_class else pr.Param) + if not is_class: + if param and tok.string == ':': + # parse annotations + annotation, tok = self._parse_statement(added_breaks=breaks) + if annotation: + param.add_annotation(annotation) - # function params without vars are usually syntax errors. - # expressions are valid in superclass declarations. - if param and (param.get_defined_names() or is_class): - param.position_nr = pos - names.append(param) - pos += 1 + # function params without vars are usually syntax errors. + # expressions are valid in superclass declarations. + if param and param.get_defined_names(): + param.position_nr = pos + params.append(param) + pos += 1 - return names + return params def _parse_function(self): """