-
-
Notifications
You must be signed in to change notification settings - Fork 513
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
Fix api.usages
so it finds cross-module usages
#899
Conversation
2a1b16b
to
3335d0d
Compare
jedi/api/usages.py
Outdated
result = evaluator.goto(context, name_node) | ||
except (NotImplementedError, RecursionError) as err: | ||
logging.getLogger(__name__).error(err) | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is not how we work here. Did you maybe just randomly check this one in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't mean to add that. I'll remove it.
BTW, I added that part a long time ago because the usages function was running into errors and then giving up. Catching the exception and continuing the loop allowed jedi to find other usages that didn't raise errors. I logged the error because I didn't want the errors to go unnoticed. What is an alternative way you would accept?
3335d0d
to
555e32b
Compare
Reposting some parts because I don't know where github put my previous comment (and yours) I've removed the try/except part. Sorry, I didn't mean to add that to the PR. I've also made a minor change to the column indices in the test code. It doesn't affect the functioning of the test but it seems more correct. BTW the try/except was because Note: The old stuff is at fix-api.usages-bad. |
Fixing the actual bug. Catching NotImplementedError is like the worst error that I've ever heard. |
I see. I (mistakenly) thought you just hadn't finished this part of Jedi, and I didn't want the unfinished part to block the user from seeing all the other usages that Jedi was able to find. By your comment, I take it that Jedi should not be raising Also, would you be OK with catching RecursionError? |
Maybe it even is, but that doesn't matter. I think open source libraries should strive for perfection and not work some of the time. If something is wrong we should fix it.
I'm not really using ABCMeta, because it would make some things slower. Using
No. I'm not ok with catching any exceptions if it's nested. These are actual bugs that you are hiding by removing I get a lot of pull requests here that just "fix" an error by catching e.g. |
Ok. This looks good. I think it's a good solution for now. I still think that usages is completely and utterly broken and we have to rewrite it, but it's a good fix for now. Would it be possible to refactor the tests a bit into a form of |
In order to refactor it into the form of |
Ok. I see! |
Jedi could not find certain cross-module usages. The problem was in how it compared contexts in
api.usages
.I've included a test that fails without my included fix.