-
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
flake8_simplify : SIM401 #1778
flake8_simplify : SIM401 #1778
Conversation
@charliermarsh please review. // test_key : &Box<Located<ExprKind>>
let test_key_comp: &ComparableExpr = (&test_key).into(); // <= failed Hope you can improve on that. |
Thank you! I wasn't able to remove that method entirely, but I was able to simplify it a bit. |
[![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://github.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://github.com/charliermarsh/ruff/releases/tag/v0.0.219) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.218...v0.0.219) #### What's Changed - Disable update check by default by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1786](https://github.com/charliermarsh/ruff/pull/1786) - Improve PIE794 autofix behavior by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1794](https://github.com/charliermarsh/ruff/pull/1794) - Convert flake8-comprehensions checks to Checker style by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1795](https://github.com/charliermarsh/ruff/pull/1795) - Refactor flake8-comprehensions rules to take fewer arguments by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1797](https://github.com/charliermarsh/ruff/pull/1797) - Avoid rewriting flake8-comprehensions expressions for builtin overrides by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1799](https://github.com/charliermarsh/ruff/pull/1799) - Update readme to reflect [#​1763](https://github.com/charliermarsh/ruff/issues/1763) by [@​Czaki](https://github.com/Czaki) in [https://github.com/charliermarsh/ruff/pull/1780](https://github.com/charliermarsh/ruff/pull/1780) - Avoid flagging builtins for OSError rewrites by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1800](https://github.com/charliermarsh/ruff/pull/1800) - Skip unused argument checks for magic methods by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1801](https://github.com/charliermarsh/ruff/pull/1801) - Skip SIM108 violations for complex if-statements by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1802](https://github.com/charliermarsh/ruff/pull/1802) - \[`flake8-simplify`] Add Rule for `SIM115` (Use context handler for opening files) by [@​saadmk11](https://github.com/saadmk11) in [https://github.com/charliermarsh/ruff/pull/1782](https://github.com/charliermarsh/ruff/pull/1782) - flake8\_simplify : SIM401 by [@​chammika-become](https://github.com/chammika-become) in [https://github.com/charliermarsh/ruff/pull/1778](https://github.com/charliermarsh/ruff/pull/1778) - Avoid erroneous Q002 error message for single-quote docstrings by [@​colin99d](https://github.com/colin99d) in [https://github.com/charliermarsh/ruff/pull/1777](https://github.com/charliermarsh/ruff/pull/1777) - Implement doc line length enforcement by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1804](https://github.com/charliermarsh/ruff/pull/1804) - Move top level `ruff` into `python` folder by [@​messense](https://github.com/messense) in [https://github.com/charliermarsh/ruff/pull/1806](https://github.com/charliermarsh/ruff/pull/1806) - Improve globset documentation and help message by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/1808](https://github.com/charliermarsh/ruff/pull/1808) #### New Contributors - [@​Czaki](https://github.com/Czaki) made their first contribution in [https://github.com/charliermarsh/ruff/pull/1780](https://github.com/charliermarsh/ruff/pull/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 <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@charliermarsh some afterthought... we are not going to flag this at all if there are comments in the |
@chammika-become - Yeah, it's really hard to preserve comments correctly since there are so many cases to handle (above the statement, below the statement, inline, etc.), so for now, I'm just skipping commented blocks when collapsing multi- to single-line statements. We do the same for the ternary-rewrite rule. I prefer keeping |
Ref #998
Notes:
flake8_simplify
only test first two (only first in second pattern)@charliermarsh I would like to handle cases marked nice-to-have (they are handled in
flake8_simplify
by flattening the expr into strings). Appreciate, any pointers in improving helpermatch_name_expr
for more complex exprs.