Skip to content

Switch to storing AST nodes on the stack for more accurate method signature check and easy access to parent nodes #623

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stefmolin
Copy link
Contributor

AST nodes have knowledge of their children, but not their parents which is why we use a stack in the DocstringVisitor. Currently it is used to track a node's unambiguous name (e.g., my_module.MyClass.__init__). This PR changes that to store the AST nodes themselves, which allows us to use a node's ancestry for more robust logic. For example, with this change, we can distinguish between a function and a method, and more precisely determine whether to ignore self and cls parameters in a signature.

Copy link
Collaborator

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little out of my depth here, but it looks reasonable to me, CIs are happy, and it should help with #622 so I'm inclined to merge. @stefanv did you want to look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants