Skip to content
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

Implement pylint's empty-comment rule (PLR2044) #5900

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jelly
Copy link

@jelly jelly commented Jul 19, 2023

Implement empty-comment
https://pylint.pycqa.org/en/latest/user_guide/messages/refactor/empty-comment.html

Issue #970

This PR is still draft as locally running cargo dev generate-all add the new PLR2044 rule, but also removes RUF014 which does not seem expected.
Also note, I've written some small programs in Rust but don't call myself experienced :)
Last note, the --fix will leave trailing spaces, but I guess that's fine as it might be tricky to determine what more to remove? Or should the code be a bit smarter and rtrim() after dropping the trailing #?

Summary

Implement pylint's empty-comment rule.

Pylint implementation https://github.com/pylint-dev/pylint/blob/c4281bcff86b66fdf8518e7f57dc3405c8da3a4f/pylint/extensions/empty_comment.py#L43

Test Plan

Manually and by running the unit test from https://github.com/pylint-dev/pylint/blob/c4281bcff86b66fdf8518e7f57dc3405c8da3a4f/tests/functional/ext/empty_comment/empty_comment.py#L4

@github-actions
Copy link

PR Check Results

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.07     12.3±0.64ms     3.3 MB/sec    1.00     11.5±0.71ms     3.5 MB/sec
formatter/numpy/ctypeslib.py               1.08      2.4±0.10ms     6.9 MB/sec    1.00      2.2±0.08ms     7.5 MB/sec
formatter/numpy/globals.py                 1.00   267.2±13.48µs    11.0 MB/sec    1.00   266.2±14.09µs    11.1 MB/sec
formatter/pydantic/types.py                1.04      5.2±0.26ms     4.9 MB/sec    1.00      5.0±0.15ms     5.1 MB/sec
linter/all-rules/large/dataset.py          1.04     17.5±0.99ms     2.3 MB/sec    1.00     16.9±0.83ms     2.4 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.10      4.4±0.28ms     3.8 MB/sec    1.00      3.9±0.11ms     4.2 MB/sec
linter/all-rules/numpy/globals.py          1.13   578.8±44.42µs     5.1 MB/sec    1.00   512.2±29.32µs     5.8 MB/sec
linter/all-rules/pydantic/types.py         1.09      7.9±0.47ms     3.2 MB/sec    1.00      7.3±0.25ms     3.5 MB/sec
linter/default-rules/large/dataset.py      1.09      8.8±0.40ms     4.6 MB/sec    1.00      8.1±0.31ms     5.0 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.05  1867.0±95.64µs     8.9 MB/sec    1.00  1782.5±94.20µs     9.3 MB/sec
linter/default-rules/numpy/globals.py      1.03   218.8±12.50µs    13.5 MB/sec    1.00   213.0±14.95µs    13.9 MB/sec
linter/default-rules/pydantic/types.py     1.05      4.0±0.38ms     6.4 MB/sec    1.00      3.8±0.20ms     6.8 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00     11.1±0.24ms     3.7 MB/sec    1.00     11.2±0.16ms     3.6 MB/sec
formatter/numpy/ctypeslib.py               1.00      2.2±0.06ms     7.6 MB/sec    1.00      2.2±0.06ms     7.6 MB/sec
formatter/numpy/globals.py                 1.00    246.4±8.95µs    12.0 MB/sec    1.04   255.5±16.78µs    11.5 MB/sec
formatter/pydantic/types.py                1.00      4.7±0.16ms     5.4 MB/sec    1.03      4.9±0.16ms     5.2 MB/sec
linter/all-rules/large/dataset.py          1.00     15.4±0.20ms     2.6 MB/sec    1.03     15.9±0.41ms     2.6 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      4.1±0.07ms     4.1 MB/sec    1.01      4.1±0.05ms     4.1 MB/sec
linter/all-rules/numpy/globals.py          1.00    490.3±7.16µs     6.0 MB/sec    1.02   500.2±10.72µs     5.9 MB/sec
linter/all-rules/pydantic/types.py         1.00      7.0±0.17ms     3.6 MB/sec    1.03      7.2±0.16ms     3.5 MB/sec
linter/default-rules/large/dataset.py      1.00      8.1±0.11ms     5.0 MB/sec    1.01      8.2±0.12ms     5.0 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1676.9±31.40µs     9.9 MB/sec    1.01  1693.3±23.28µs     9.8 MB/sec
linter/default-rules/numpy/globals.py      1.00    189.7±4.81µs    15.6 MB/sec    1.04   196.6±12.24µs    15.0 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.6±0.05ms     7.1 MB/sec    1.01      3.6±0.06ms     7.0 MB/sec

@zanieb
Copy link
Contributor

zanieb commented Jul 19, 2023

Welcome! Thanks for contributing :)

This PR is still draft as locally running cargo dev generate-all add the new PLR2044 rule, but also removes RUF014 which does not seem expected.

This should be resolved by #5832 — sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants