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
-1
View File
@@ -324,7 +324,6 @@ class Evaluator(object):
# statement name definitions. Only return, if it's one name and one # statement name definitions. Only return, if it's one name and one
# name only. Otherwise it's a mixture between a definition and a # 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. # 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) \ 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()]: and call_path[0] in [d.names[-1] for d in stmt.get_defined_names()]:
return [call_path[0]] return [call_path[0]]
+18 -14
View File
@@ -182,27 +182,31 @@ class Parser(object):
:return: List of Statements :return: List of Statements
:rtype: list :rtype: list
""" """
names = [] params = []
tok = None tok = None
pos = 0 pos = 0
breaks = [',', ':'] breaks = [',', ':']
while tok is None or tok.string not in (')', ':'): 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, param, tok = self._parse_statement(added_breaks=breaks,
stmt_class=pr.Param) stmt_class=pr.Statement
if param and tok.string == ':': if is_class else pr.Param)
# parse annotations if not is_class:
annotation, tok = self._parse_statement(added_breaks=breaks) if param and tok.string == ':':
if annotation: # parse annotations
param.add_annotation(annotation) annotation, tok = self._parse_statement(added_breaks=breaks)
if annotation:
param.add_annotation(annotation)
# function params without vars are usually syntax errors. # function params without vars are usually syntax errors.
# expressions are valid in superclass declarations. # expressions are valid in superclass declarations.
if param and (param.get_defined_names() or is_class): if param and param.get_defined_names():
param.position_nr = pos param.position_nr = pos
names.append(param) params.append(param)
pos += 1 pos += 1
return names return params
def _parse_function(self): def _parse_function(self):
""" """