Closed pylint-bot closed 8 years ago
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):
Could you give me an example where the root doesn't have a name attribute? I presume this is the case for nodes for which their root is not a Module, which is wrong, .root() should always return a Module.
Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:
I first encountered this problem in debugging astroid, which may well have involved an incorrectly-generated AST. However, I'm more thinking about Macropy and similar code generation applications which can involve splicing pieces of an AST into another AST or building an AST from the bottom up rather than the top down.
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):
Right, it makes sense for an AST not to have Module as root. Care to work on a patch?
Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:
I will work on a patch once I'm finished with the node constructor patch.
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):
No problem. I'll do more reviews for your PR next week, since I'm pretty full with EuroPython right now.
Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:
Fixed by https://bitbucket.org/logilab/astroid/commits/7b127880987d8896349e070debaccc587a3c6570
Originally reported by: BitBucket: ceridwenv, GitHub: @ceridwen?
NodeNG's
__repr__
includes a call toself.root().name
, which will fail on an AST fragment whose root doesn't have a name attribute. This is mostly an inconvenience when trying to debug the process of building ASTs.