-
Notifications
You must be signed in to change notification settings - Fork 2
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
Print the line from where the issue is raised #34
Comments
I think you could modify this function: def _add_exception(self, name: str):
self.raw_exceptions.append(name)
if name not in self.found_exceptions:
self.found_exceptions.append(name) Make it take a node instead of name. Then create a function that prints all the Exceptions in the format you expect. Like: def print_exceptions(self):
for exception in self.found_exceptions:
print(f"Found {exception.name} on line {exception.lineno}`) I think something like that would work? |
Yes that's kind of what I've tried. But I've never been able to recover the file from which the line is from. So when analyzing multi file code, it would not work :( |
Do you need the path to the file or the name of it? The path might not be that helpful as it's usually pretty long. |
Ideally the path when one want to find exceptions raised in a lot of submodules, for example i was using it to find errors raised by a complex dataloader. |
Hi :)
Great lib!
In the example with exceptions, do you see a way to report the line where the issue is raised?
The use case would be to understand where the issue is raised, and if one should try to handle it or not. Having the context of the "raise" line makes it easier to understand what is the error (especially with often used exception like TypeError).
example:
{'ValueError': 'Line 13,
'TypeError': 'Line 17'}
I'm not very familiar with AST but seems that one can get the attributes 'lineno', 'col_offset', 'end_lineno', 'end_col_offset' for which node. We still need to trace parents to get like where in the file is this from.
If you have an idea of how to do this, I can implement it. :)
The text was updated successfully, but these errors were encountered: