Class inheritance definitions shouldn't be params. It's just statements.

This commit is contained in:
Dave Halter
2014-09-04 12:28:50 +02:00
parent 1df025c39d
commit 06699993f1
2 changed files with 18 additions and 15 deletions

View File

@@ -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]]

View File

@@ -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):
"""