-
Notifications
You must be signed in to change notification settings - Fork 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
Implement doc line length enforcement #1804
Conversation
fb31e88
to
b80812b
Compare
This PR implements `W505` (`DocLineTooLong`), which is similar to `E501` (`LineTooLong`) but confined to doc lines. I based the "doc line" definition on pycodestyle, which defines a doc line as a standalone comment or string statement. Our definition is a bit more liberal, since we consider any string statement a doc line (even if it's part of a multi-line statement) -- but that seems fine to me. Note that, unusually, this rule requires custom extraction from both the token stream (to find standalone comments) and the AST (to find string statements). Closes #1784.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.218` -> `^0.0.219` | [![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.219/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.219/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.219/compatibility-slim/0.0.218)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.219/confidence-slim/0.0.218)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.219`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.219) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.218...v0.0.219) #### What's Changed - Disable update check by default by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1786 - Improve PIE794 autofix behavior by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1794 - Convert flake8-comprehensions checks to Checker style by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1795 - Refactor flake8-comprehensions rules to take fewer arguments by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1797 - Avoid rewriting flake8-comprehensions expressions for builtin overrides by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1799 - Update readme to reflect [#​1763](https://togithub.com/charliermarsh/ruff/issues/1763) by [@​Czaki](https://togithub.com/Czaki) in [astral-sh/ruff#1780 - Avoid flagging builtins for OSError rewrites by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1800 - Skip unused argument checks for magic methods by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1801 - Skip SIM108 violations for complex if-statements by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1802 - \[`flake8-simplify`] Add Rule for `SIM115` (Use context handler for opening files) by [@​saadmk11](https://togithub.com/saadmk11) in [astral-sh/ruff#1782 - flake8\_simplify : SIM401 by [@​chammika-become](https://togithub.com/chammika-become) in [astral-sh/ruff#1778 - Avoid erroneous Q002 error message for single-quote docstrings by [@​colin99d](https://togithub.com/colin99d) in [astral-sh/ruff#1777 - Implement doc line length enforcement by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1804 - Move top level `ruff` into `python` folder by [@​messense](https://togithub.com/messense) in [astral-sh/ruff#1806 - Improve globset documentation and help message by [@​charliermarsh](https://togithub.com/charliermarsh) in [astral-sh/ruff#1808 #### New Contributors - [@​Czaki](https://togithub.com/Czaki) made their first contribution in [astral-sh/ruff#1780 **Full Changelog**: astral-sh/ruff@v0.0.218...v0.0.219 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45OC4xIiwidXBkYXRlZEluVmVyIjoiMzQuOTguMSJ9--> Signed-off-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Thank you! Much appreciated ❤️ |
@stinodego - Of course! Let me know if you notice any discrepancies. I'm detecting "doc lines" using a different strategy, but it should have identical behavior apart from a few weird edge cases (like multi-line statements that contain string expressions, e.g., |
I just tried to break it a few different ways, and it seems to work just fine for all the use cases I could come up with! Will let you know if I run into anything odd. |
This PR implements
W505
(DocLineTooLong
), which is similar toE501
(LineTooLong
) but confined to doc lines.I based the "doc line" definition on pycodestyle, which defines a doc line as a standalone comment or string statement. Our definition is a bit more liberal, since we consider any string statement a doc line (even if it's part of a multi-line statement) -- but that seems fine to me.
Note that, unusually, this rule requires custom extraction from both the token stream (to find standalone comments) and the AST (to find string statements).
Closes #1784.