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
bpo-42116: Fix inspect.getsource handling of trailing comments #23630
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. |
|
Thanks @iritkatriel for the PR, and @taleinat for merging it |
…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