-
-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing NodeNG.nearest method #691
Comments
Thanks @kavins14 Makes sense to fix this, but I wonder if it's not better to remove this method altogether. Someone might use it in a |
By defining |
Sounds good, we can reuse the current issue and PR for the same effect. |
EDIT:
Based on discussions below we have decided to remove this method altogether because it's not being used in
astroid
orpylint
and that it doesn't seem to have any use in the near future.Steps to reproduce
Run this script:
Current behavior
middle.nearest([before, after])
returnsbefore
.Expected behavior
middle.nearest([before, after])
should returnafter
since it's closerIssue Description
The issue is that for a NodeNG node
n
,n.nearest
method only returns the nearest node that occurs on lines beforen
and disregards any nodes on the lines after.https://github.com/PyCQA/astroid/blob/33488e28677a1e980361757cdb1db0eb13c99435/astroid/node_classes.py#L582-L607
I see two possible fixes for this:
I think that fix (1) is in line with method description so I will be making a PR for this.
Note: There is no usage of
NodeNG.nearest
in bothpylint
's andastroid
's source code.python -c "from astroid import __pkginfo__; print(__pkginfo__.version)"
output2.3.0
The text was updated successfully, but these errors were encountered: