Add get_source_segment and support trailing comments in functions#19
Add get_source_segment and support trailing comments in functions#19devdanzin wants to merge 1 commit intot3rn0:masterfrom
Conversation
|
Hi. Thanks for creating this PR. There are two separate nodes and there are two separate source segments. Now, let's change the b-node to a comment: Again, we have two separate nodes (Expr and Comment) and two separate source segments. I don't see any difference between the first and second examples, except for the ast node type. About PR: I recommend creating this modification on your side (in radon). It's really great you raised this issue. Review helped me to find one minor bug 🙂 |
|
Thank you for reviewing this! I agree with your analysis, glad to hear that it helped spot a minor bug :) |
I've made some changes to ast-comments while trying to get a version of ast.get_source_segment that roundtrips comments to use in radon.
They allow getting trailing comments from within function bodies. Unfortunately, it'll also incorporate comments that appear right after a function's body. I'm not sure this is of interest to include in ast-comments, but wanted to keep a record of the exploration and allow assessing whether (an improved version of?) this would be desirable.