ERA001
: Ignore script-comments with multiple end-tags
#13283
Merged
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
# /// script
and 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