ERA001: Ignore script-comments with multiple end-tags#13283
Merged
MichaReiser merged 1 commit intomainfrom Sep 9, 2024
Merged
Conversation
f718e9a to
ac8b453
Compare
Contributor
|
charliermarsh
approved these changes
Sep 9, 2024
Member
charliermarsh
left a comment
There was a problem hiding this comment.
We also have an implementation for this in uv. You could consider copying that over, but this is also fine. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A script-comment according to PEP 723 starts with
# /// scriptand spans all lines up to# ///.However, the
´# ///isn't considered the end-tag if the next line is a valid content line according to PEP 723 (#or#<space>).This PR fixes the handling of script-comments with multipe end-tags.
Fixes #13278
Discussion
This PR changes the rule's semantics to not skip over invalid script comments. Any code in invaid-script comments will get flagged.
I'm torn if that's the right behavior. Arguably, detecting invalid-script-comments should be its own rule. However,
the spec is very cleary about unclosed blocks:
Test Plan
Added and update tests