-
Notifications
You must be signed in to change notification settings - Fork 19
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
Architecture: Figure out how to get context #21
Comments
@MartinThoma Here you go. To get context you just need to extend the ASTNodeVisitor: https://stackoverflow.com/questions/43166571/getting-all-the-nodes-from-python-ast-that-correspond-to-a-particular-variable-w |
@MartinThoma Or better yet transformers.ParentChildNodeTransformer in astmonkey should work well. One of the AST libraries in the list should prove helpful: https://github.com/gyermolenko/awesome-python-ast |
After looking around, I really think astpath should be able to do queries with all the context you realistically need: (check the ReadMe: https://github.com/hchasestevens/astpath) |
Thank you! This week (and probably all the time until Christmas) is super busy for me. I don't think I will have the time to look into it. But feel free to create a PR :-) |
https://stackoverflow.com/a/43311383/562769 might be it |
It's fixed: e301b8f - now every node has a |
@MartinThoma Could have also just used typing .cast |
@Skylion007 Where? And cast to what? Feel free to make a PR if you see a simpler solution :-) |
Ah, nvm you are using dynamic attrs. Yeah, that will only work if you mark parent as an optional value and subclass them all. :/ |
Several issues are blocked, because I don't know yet how to get context.
For example, SIM 201 prevents
not a==b
and suggestsa != b
. In general, this seems to be a good rule.As an exception, I want to leave it like this when it's in the context of throwing exceptions:
But for this I need to know that the boolean operation
not (a ==b)
is in the context of an if-statement.The text was updated successfully, but these errors were encountered: