Documentation: never use updated_node
to access node metadata
#882
Labels
documentation
Improvements or additions to documentation
updated_node
to access node metadata
#882
How was this snippet executed:
python -m pytest test_main.py
What was expected to happen:
The test runs and succeeds, with the print statement echoing something along the lines of
metadata.GlobalScope
What actually happened:
The test fails, with an error related to not being able to lookup the scopage of the
libcst.AnnAssign
.This happens similarly for
PositionProvider
, and presumably for all metadata providers and all derivates oflibcst.CSTNode
.Without reading into it too much, I assume that some copying takes place after calculating the metadata for the passed
Module
, which causes lookups to fail as they are driven by object identity?Stepping into the
leave_AnnAssign
method reveals that there is a suitablelibcst.AnnAssign
node stored in the metadata fromScopeProvider
, but the lookup will fail nonetheless.Of course, perhaps I am simply approaching this wrong, and would be glad to correct any bug I have introduced here!
The text was updated successfully, but these errors were encountered: