-
-
Notifications
You must be signed in to change notification settings - Fork 294
extract_node() skips doc_node #2675
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
Comments
I think this is intended? The |
Does it? Okay. Maybe the reason why it's confusing is that there's no clear
distinction between what is and isn't a phantom node. Note that, under the
standard python ast module, it stays as a string const. I imagine the ast
module is typically what people are migrating from.
Should the function explicitly fail if it can't find a node at the line
(exception)?
…On Mon, Feb 3, 2025, 9:25 AM Daniël van Noord ***@***.***> wrote:
I think this is intended? The doc_node is a phantom node that doesn't
really exists in the AST like the normal nodes. It makes sense to have to
extract the parent node?
—
Reply to this email directly, view it on GitHub
<#2675 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQPQISWLOF7ITY3FZG22S32N535TAVCNFSM6AAAAABWJKDSX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZRGE2TAMZXG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Perhaps, that might indeed be a nicer API. We can probably also change it to also find the |
Okay. Either option seems viable. If the astroid team is interested in
making this change, let me know if I can provide assistance. I suspect this
qualifies as an interface breaking change.
…On Mon, Feb 3, 2025, 9:48 AM Daniël van Noord ***@***.***> wrote:
Perhaps, that might indeed be a nicer API.
We can probably also change it to also find the doc_node. astroid
sometimes diverts from the behaviour that seems sensible from a stdlib.ast
perspective as it is really tuned towards the needs of pylint. I think
that is also what happened in this case.
—
Reply to this email directly, view it on GitHub
<#2675 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQPQISEQLSQ7G2CE5QUJU32N56U5AVCNFSM6AAAAABWJKDSX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMMZRGIYTEOBWGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
If you place a
#@
marker on a line that's a ClassDef's docstring node, extract_node() doesn't seem to pick it out. When debugging, I noticed that the line number was properly being extracted, butdoc_node
wasn't being included in the children being searched for that line number. I worked around this by placing#@
on the ClassDef itself, and then manually extracting the doc_node.The version of astroid was whatever pylint v3.3.4 pulls in.
The text was updated successfully, but these errors were encountered: