You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AST Rewriter doesn't correctly detect the whole comment when it is multiline #189
Currently, the AST rewriter only assumes a comment is a single line long. It doesn't account for a comment being longer than that.
For example, in this case, only the line "# comment" would be marked as the comment and the earlier lines will be considered separate comments.
# This
# Is
# A
# Multiline
# Comment
[ enter func here ]
@staticmethod
def get_comment_location(start_offset: int, stop_offset: int, content: bytes) -> tuple[int, int]:
"""Get the location of the comment before the location, but after the stop_location
a comment is a line that starts with // or a block that starts with /* and ends with */
or a line that starts with #.
"""
# search last occurrence of //, /*, # in a byte array
comment_start = content.rfind(b"//", start_offset, stop_offset)
if comment_start != -1:
comment_end = _RewriteActions.__get_end_of_line(content, comment_start)
return comment_start, comment_end
comment_start = content.rfind(b"/*", start_offset, stop_offset)
if comment_start != -1:
comment_end = content.find(b"*/", comment_start, stop_offset)
if comment_end != -1:
comment_end += len("*/")
return comment_start, comment_end
comment_start = content.rfind(b"#", start_offset, stop_offset)
if comment_start != -1:
comment_end = _RewriteActions.__get_end_of_line(content, comment_start)
return comment_start, comment_end
return -1, -1
This seems to me like an oversight. It is not that uncommon for a comment to be longer than a few lines, and still mention the same thing.
Activity
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget
Bring #202 within the lint budget