From 6161910d4775138955b3455d7221646fb0a730a2 Mon Sep 17 00:00:00 2001 From: kavins14 Date: Tue, 10 Sep 2019 04:22:52 -0400 Subject: Remove NodeNG.nearest method (#692) The NodeNG.nearest method was not working properly as outlined in #691 and seem to not be in use at all across astroid and pylint. Close #691 --- ChangeLog | 4 ++++ astroid/node_classes.py | 27 --------------------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf4893ac..0c4c3e24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,10 @@ What's New in astroid 2.3.0? ============================ Release Date: TBA +* Remove NodeNG.nearest method because of lack of usage in astroid and pylint. + + Close #691 + * Allow importing wheel files. Close #541 * Annotated AST follows PEP8 coding style when converted to string. diff --git a/astroid/node_classes.py b/astroid/node_classes.py index 5adb1a03..b9af5983 100644 --- a/astroid/node_classes.py +++ b/astroid/node_classes.py @@ -579,33 +579,6 @@ class NodeNG: """ return self.parent.previous_sibling() - def nearest(self, nodes): - """Get the node closest to this one from the given list of nodes. - - :param nodes: The list of nodes to search. All of these nodes must - belong to the same module as this one. The list should be - sorted by the line number of the nodes, smallest first. - :type nodes: iterable(NodeNG) - - :returns: The node closest to this one in the source code, - or None if one could not be found. - :rtype: NodeNG or None - """ - myroot = self.root() - mylineno = self.fromlineno - nearest = None, 0 - for node in nodes: - assert node.root() is myroot, ( - "nodes %s and %s are not from the same module" % (self, node) - ) - lineno = node.fromlineno - if node.fromlineno > mylineno: - break - if lineno > nearest[1]: - nearest = node, lineno - # FIXME: raise an exception if nearest is None ? - return nearest[0] - # these are lazy because they're relatively expensive to compute for every # single node, and they rarely get looked at -- cgit v1.2.1