diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2016-01-25 00:24:38 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-01-25 00:24:38 +0200 |
commit | 35ba13cf470ffca09cf97e65ce2c7fa75c0025e5 (patch) | |
tree | dc7c6f3ea884cb067feb7b693a9400c83bac4f78 /astroid/tree/node_classes.py | |
parent | eb48cf362e413e29c0ddaa7c7d0c88a7db0be95a (diff) | |
download | astroid-git-35ba13cf470ffca09cf97e65ce2c7fa75c0025e5.tar.gz |
Don't set the fromlineno of parents or children for nodes without it set
If a node had a .fromlineno as None, then a function would be invoked
which retrieved the first line number of the children or the parents which
wasn't none. This is wrong, because it's not a guarantee that all nodes should
have it set, especially those coming from raw_building, where it can be close
to impossible to determine the line number of an object coming from an
extension module. The functionality was removed and certain guards
were added in a couple of places in order to protect operations against
None.
Close #310 and #195
Diffstat (limited to 'astroid/tree/node_classes.py')
-rw-r--r-- | astroid/tree/node_classes.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/astroid/tree/node_classes.py b/astroid/tree/node_classes.py index 78a9afc8..722e2b75 100644 --- a/astroid/tree/node_classes.py +++ b/astroid/tree/node_classes.py @@ -185,8 +185,11 @@ class Arguments(base.AssignTypeMixin, AssignedStmtsMixin, base.NodeNG): @decorators.cachedproperty def fromlineno(self): - lineno = super(Arguments, self).fromlineno - return max(lineno, self.parent.fromlineno or 0) + # Let the Function's lineno be the lineno for this. + if self.parent.fromlineno: + return self.parent.fromlineno + + return super(Arguments, self).fromlineno def format_args(self): """return arguments formatted as string""" |