Skip to content

[pylint] invalid-characters-*#3552

Merged
charliermarsh merged 6 commits into
astral-sh:mainfrom
r3m0t:chars-b
Mar 17, 2023
Merged

[pylint] invalid-characters-*#3552
charliermarsh merged 6 commits into
astral-sh:mainfrom
r3m0t:chars-b

Conversation

@r3m0t
Copy link
Copy Markdown
Contributor

@r3m0t r3m0t commented Mar 15, 2023

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

✅ ecosystem check detected no changes.

Comment thread crates/ruff/src/settings/rule_table.rs Outdated
Comment on lines +30 to +32
pub fn any_enabled(&self, codes: &[&Rule]) -> bool {
codes.iter().any(|c| self.enabled.contains_key(c))
}
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser Mar 16, 2023

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:

  1. Change Rule to implement Copy (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
  2. Accept any iterable
Suggested change
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,
    ]);

Comment thread crates/ruff/src/checkers/tokens.rs Outdated
&Rule::UselessSemicolon,
]);
let enforce_invalid_escape_sequence = settings.rules.enabled(&Rule::InvalidEscapeSequence);
let enforce_implicit_string_concatenation = settings
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Use any_enabled?

Comment thread crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs Outdated
Comment thread crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs Outdated
Comment thread crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs Outdated
Comment thread crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs Outdated
Comment thread crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs Outdated
@r3m0t r3m0t requested a review from MichaReiser March 16, 2023 21:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 16, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     13.7±0.07ms     3.0 MB/sec    1.01     13.8±0.06ms     2.9 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.6±0.02ms     4.6 MB/sec    1.00      3.6±0.01ms     4.6 MB/sec
linter/all-rules/numpy/globals.py          1.00    500.7±1.06µs     5.9 MB/sec    1.00    501.6±1.28µs     5.9 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.1±0.02ms     4.2 MB/sec    1.00      6.1±0.02ms     4.2 MB/sec
linter/default-rules/large/dataset.py      1.00      7.6±0.03ms     5.4 MB/sec    1.01      7.6±0.02ms     5.3 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1682.3±2.35µs     9.9 MB/sec    1.01   1704.6±1.41µs     9.8 MB/sec
linter/default-rules/numpy/globals.py      1.00    193.2±0.47µs    15.3 MB/sec    1.01    195.3±1.55µs    15.1 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.5±0.01ms     7.3 MB/sec    1.02      3.6±0.01ms     7.2 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
linter/all-rules/large/dataset.py          1.00     16.0±0.14ms     2.5 MB/sec    1.00     15.9±0.15ms     2.6 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      4.2±0.05ms     3.9 MB/sec    1.00      4.2±0.10ms     3.9 MB/sec
linter/all-rules/numpy/globals.py          1.01    543.2±8.31µs     5.4 MB/sec    1.00    538.5±5.52µs     5.5 MB/sec
linter/all-rules/pydantic/types.py         1.00      7.0±0.07ms     3.6 MB/sec    1.00      7.0±0.06ms     3.7 MB/sec
linter/default-rules/large/dataset.py      1.00      9.0±0.08ms     4.5 MB/sec    1.01      9.1±0.07ms     4.5 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1957.9±23.64µs     8.5 MB/sec    1.00  1953.3±15.28µs     8.5 MB/sec
linter/default-rules/numpy/globals.py      1.00    213.3±3.94µs    13.8 MB/sec    1.02    217.3±9.23µs    13.6 MB/sec
linter/default-rules/pydantic/types.py     1.00      4.1±0.04ms     6.2 MB/sec    1.01      4.2±0.17ms     6.1 MB/sec

@charliermarsh
Copy link
Copy Markdown
Member

Sorry for the delay, will get to this tomorrow.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Mar 17, 2023
@charliermarsh charliermarsh enabled auto-merge (squash) March 17, 2023 19:09
@charliermarsh charliermarsh changed the title [pylint] invalid-characters-* [pylint] invalid-characters-* Mar 17, 2023
@charliermarsh charliermarsh merged commit 1dd3cbd into astral-sh:main Mar 17, 2023
renovate Bot referenced this pull request in ixm-one/pytest-cmake-presets Mar 18, 2023
[![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.256` ->
`^0.0.257` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/compatibility-slim/0.0.256)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/confidence-slim/0.0.256)](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
[@&#8203;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
[@&#8203;johnor](https://togithub.com/johnor) in
[https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550)
- \[`pylint`] invalid-characters-\* by
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3583](https://togithub.com/charliermarsh/ruff/pull/3583)

#### New Contributors

- [@&#8203;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 <bot@renovateapp.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate Bot referenced this pull request in allenporter/flux-local Mar 21, 2023
[![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.256` ->
`==0.0.257` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/compatibility-slim/0.0.256)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.257/confidence-slim/0.0.256)](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
[@&#8203;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
[@&#8203;johnor](https://togithub.com/johnor) in
[https://github.com/charliermarsh/ruff/pull/3550](https://togithub.com/charliermarsh/ruff/pull/3550)
- \[`pylint`] invalid-characters-\* by
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;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
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3583](https://togithub.com/charliermarsh/ruff/pull/3583)

#### New Contributors

- [@&#8203;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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants