[pylint] Implement empty-comment (PLR2044)#9174
[pylint] Implement empty-comment (PLR2044)#9174charliermarsh merged 7 commits intoastral-sh:mainfrom
pylint] Implement empty-comment (PLR2044)#9174Conversation
2ef2331 to
464a094
Compare
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| PLR2044 | 25 | 25 | 0 | 0 | 0 |
| PLC0415 | 2 | 1 | 1 | 0 | 0 |
| PLR6301 | 2 | 1 | 1 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
|
Looks like the ecosystem checks found some edge cases not currently covered:
|
|
Nice, thanks for kicking this off! Agreed on the edge cases described above. |
464a094 to
f26eda6
Compare
There was a problem hiding this comment.
- Add test for "empty comment" lines in multi-line strings/comments
- Add test for "empty comment" lines in block comments
f26eda6 to
c2de5d1
Compare
# -- Methods following the EthereumModule interface -- # |
|
c2de5d1 to
3a4d1e1
Compare
b203d24 to
09b446a
Compare
09b446a to
3e15b26
Compare
charliermarsh
left a comment
There was a problem hiding this comment.
This looks great, I really like what I'm seeing in the ecosystem checks too -- thank you!
I'm going to explore making this a token-based rule rather than a physical line-based rule, just because we want to avoid using physical lines when possible, but it'll be a mostly mechanical change...
I agree, we shouldn't flag these.
I agree, flagging empty comments within a multi-line string seems like a bug to me. |
|
Out of curiosity, why? |
Primarily because physical line-based approaches tend to be slower, since we need to run the rule over every line. This rule is actually a good example: we already know the locations of all comments in the file (via |
pylint] Implement empty-comment (PLR2044)
charliermarsh
left a comment
There was a problem hiding this comment.
This is great work! I ended up moving to the token checker, and added support for the case in which we have multiple consecutive empty comments.
Summary
Part of #970.
This adds Pylint's R0244 empty_comment lint as well as an always-safe fix.
Test Plan
The included snapshot verifies the following:
Comparison to Pylint
Running Ruff and Pylint 3.0.3 with Python 3.12.0 against the
empty_comment.pyfile added in this PR, we see the following:Identical behavior:
Differing behavior: