-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[pylint
] Implement empty-comment
(PLR2044
)
#9174
[pylint
] Implement empty-comment
(PLR2044
)
#9174
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Rebase
b203d24
to
09b446a
Compare
09b446a
to
3e15b26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.py
file added in this PR, we see the following:Identical behavior:
Differing behavior: