-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-42116: Fix inspect.getsource handling of trailing comments #23630
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
Conversation
ISTM that we should only include comments indented at least as much as the function's inner indentation, rather than anything more than the outer indentation. For example, in the following case, I would not expect the comment to be considered part of the function's code: def foo():
print("Hello")
# a comment? |
That's a good idea. It will make the code simpler, and we're talking about a non-PEP8 compliant edge case anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one minor suggestion for one of the test cases.
Thanks @iritkatriel for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
…nGH-23630) (cherry picked from commit 6e1eec7) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
GH-23643 is a backport of this pull request to the 3.9 branch. |
…nGH-23630) (cherry picked from commit 6e1eec7) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
GH-23644 is a backport of this pull request to the 3.8 branch. |
) (cherry picked from commit 6e1eec7) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
) (cherry picked from commit 6e1eec7) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
https://bugs.python.org/issue42116