summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkavins14 <kavin.singh@mail.utoronto.ca>2019-09-10 04:22:52 -0400
committerClaudiu Popa <pcmanticore@gmail.com>2019-09-10 10:22:52 +0200
commit6161910d4775138955b3455d7221646fb0a730a2 (patch)
tree38991f0cd9cddfa4a313cab23ee88cdffe14c0e6
parent8ae94aa2e12817a366350326293333ae4ba3351d (diff)
downloadastroid-git-6161910d4775138955b3455d7221646fb0a730a2.tar.gz
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
-rw-r--r--ChangeLog4
-rw-r--r--astroid/node_classes.py27
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