-
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
] invalid-characters-*
#3552
Conversation
✅ ecosystem check detected no changes. |
pub fn any_enabled(&self, codes: &[&Rule]) -> bool { | ||
codes.iter().any(|c| self.enabled.contains_key(c)) | ||
} |
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.
Neat!
We can improve the ergonomics (reduce the amount of &
a caller must write) by:
- Change
Rule
to implementCopy
(Rule is only 2 bytes large, which is cheaper than passing a reference that is 8 bytes) by changing the derive macro here Edit: see refactor: Add Copy implementation to Rule #3556 - Accept any iterable
pub fn any_enabled(&self, codes: &[&Rule]) -> bool { | |
codes.iter().any(|c| self.enabled.contains_key(c)) | |
} | |
pub fn any_enabled(&self, codes: impl IntoIterator<Item=Rule>) -> bool { | |
codes.into_iter().any(|c| self.enabled.contains_key(c)) | |
} |
You can then use it like this
let enforce_ambiguous_unicode_character = settings.rules.any_enabled([
Rule::AmbiguousUnicodeCharacterString,
Rule::AmbiguousUnicodeCharacterDocstring,
Rule::AmbiguousUnicodeCharacterComment,
]);
crates/ruff/src/checkers/tokens.rs
Outdated
&Rule::MultipleStatementsOnOneLineColon, | ||
&Rule::MultipleStatementsOnOneLineSemicolon, | ||
&Rule::UselessSemicolon, | ||
]); | ||
let enforce_invalid_escape_sequence = settings.rules.enabled(&Rule::InvalidEscapeSequence); | ||
let enforce_implicit_string_concatenation = settings |
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.
Nit: Use any_enabled
?
crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs
Outdated
Show resolved
Hide resolved
crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs
Outdated
Show resolved
Hide resolved
crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs
Outdated
Show resolved
Hide resolved
crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs
Outdated
Show resolved
Hide resolved
crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Micha Reiser <[email protected]>
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
Sorry for the delay, will get to this tomorrow. |
pylint
] invalid-characters-*
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `^0.0.256` -> `^0.0.257` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.257`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.257) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.256...v0.0.257) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`ruff`] Prefer `itertools.pairwise()` over `zip()` for successive pairs (`RUF007`) by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/3501](https://togithub.com/charliermarsh/ruff/pull/3501) - \[`flake8-bugbear`] Add `no-explicit-stacklevel` (`B028`) by [@​johnor](https://togithub.com/johnor) in [https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550) - \[`pylint`] invalid-characters-\* by [@​r3m0t](https://togithub.com/r3m0t) in [https://github.com/charliermarsh/ruff/pull/3552](https://togithub.com/charliermarsh/ruff/pull/3552) - \[`pylint`] Implement `useless-return` (`R1711`) by [@​tomecki](https://togithub.com/tomecki) in [https://github.com/charliermarsh/ruff/pull/3116](https://togithub.com/charliermarsh/ruff/pull/3116) - \[`pylint`]: Implement `continue-in-finally` (`E0116`) by [@​latonis](https://togithub.com/latonis) in [https://github.com/charliermarsh/ruff/pull/3541](https://togithub.com/charliermarsh/ruff/pull/3541) ##### Bug Fixes - Rewrite mock import with starred imports by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3566](https://togithub.com/charliermarsh/ruff/pull/3566) - Respect `type` overrides in E721 by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3582](https://togithub.com/charliermarsh/ruff/pull/3582) - Use `value > max` style in pylint and mccabe messages by [@​edgarrmondragon](https://togithub.com/edgarrmondragon) in [https://github.com/charliermarsh/ruff/pull/3553](https://togithub.com/charliermarsh/ruff/pull/3553) - Fix autofix conflict between `D209` and `D400` by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3564](https://togithub.com/charliermarsh/ruff/pull/3564) - Avoid C1901 violations within subscripts by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3517](https://togithub.com/charliermarsh/ruff/pull/3517) - Avoid adding dashed line outside of docstring by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3581](https://togithub.com/charliermarsh/ruff/pull/3581) - Enable ANSI colors on Windows 10 by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3583](https://togithub.com/charliermarsh/ruff/pull/3583) #### New Contributors - [@​johnor](https://togithub.com/johnor) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550) **Full Changelog**: astral-sh/ruff@v0.0.256...v0.0.257 </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:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTAuMiJ9--> Signed-off-by: Renovate Bot <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://togithub.com/charliermarsh/ruff) | `==0.0.256` -> `==0.0.257` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.257`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.257) [Compare Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.256...v0.0.257) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`ruff`] Prefer `itertools.pairwise()` over `zip()` for successive pairs (`RUF007`) by [@​evanrittenhouse](https://togithub.com/evanrittenhouse) in [https://github.com/charliermarsh/ruff/pull/3501](https://togithub.com/charliermarsh/ruff/pull/3501) - \[`flake8-bugbear`] Add `no-explicit-stacklevel` (`B028`) by [@​johnor](https://togithub.com/johnor) in [https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550) - \[`pylint`] invalid-characters-\* by [@​r3m0t](https://togithub.com/r3m0t) in [https://github.com/charliermarsh/ruff/pull/3552](https://togithub.com/charliermarsh/ruff/pull/3552) - \[`pylint`] Implement `useless-return` (`R1711`) by [@​tomecki](https://togithub.com/tomecki) in [https://github.com/charliermarsh/ruff/pull/3116](https://togithub.com/charliermarsh/ruff/pull/3116) - \[`pylint`]: Implement `continue-in-finally` (`E0116`) by [@​latonis](https://togithub.com/latonis) in [https://github.com/charliermarsh/ruff/pull/3541](https://togithub.com/charliermarsh/ruff/pull/3541) ##### Bug Fixes - Rewrite mock import with starred imports by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3566](https://togithub.com/charliermarsh/ruff/pull/3566) - Respect `type` overrides in E721 by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3582](https://togithub.com/charliermarsh/ruff/pull/3582) - Use `value > max` style in pylint and mccabe messages by [@​edgarrmondragon](https://togithub.com/edgarrmondragon) in [https://github.com/charliermarsh/ruff/pull/3553](https://togithub.com/charliermarsh/ruff/pull/3553) - Fix autofix conflict between `D209` and `D400` by [@​JonathanPlasse](https://togithub.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3564](https://togithub.com/charliermarsh/ruff/pull/3564) - Avoid C1901 violations within subscripts by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3517](https://togithub.com/charliermarsh/ruff/pull/3517) - Avoid adding dashed line outside of docstring by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3581](https://togithub.com/charliermarsh/ruff/pull/3581) - Enable ANSI colors on Windows 10 by [@​charliermarsh](https://togithub.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3583](https://togithub.com/charliermarsh/ruff/pull/3583) #### New Contributors - [@​johnor](https://togithub.com/johnor) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550) **Full Changelog**: astral-sh/ruff@v0.0.256...v0.0.257 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, 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/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTQuMiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
No description provided.