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

[pylint] W0603: global-statement #3227

Merged
merged 3 commits into from
Feb 26, 2023

Conversation

igozali
Copy link
Contributor

@igozali igozali commented Feb 25, 2023

Implements pylint rule W0603: global-statement.

Currently checks for global statement usage in a few StmtKinds (as tested in the pylint global-statement test case here):

  • Assign
  • AugAssign
  • ClassDef
  • FunctionDef | AsyncFunctionDef
  • Import
  • ImportFrom
  • Delete

Tracking issue is located here: #970

Output comparison:

pylint

[11:53:57 | last: 1s] (  4) | ~/src/ruff
igozali@hostname $ pylint --version
pylint 2.16.2
astroid 2.14.2
Python 3.9.9 (main, Dec  9 2022, 10:29:03)
[Clang 14.0.0 (clang-1400.0.29.202)]

[11:54:20 | last: 0s] (  0) | ~/src/ruff
igozali@hostname $ pylint -d R,C,W,E --enable W0603 --score=n crates/ruff/resources/test/fixtures/pylint/global_statement.py
************* Module global_statement
crates/ruff/resources/test/fixtures/pylint/global_statement.py:14:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:21:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:27:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:33:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:40:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:47:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:57:4: W0603: Using the global statement (global-statement)
crates/ruff/resources/test/fixtures/pylint/global_statement.py:67:4: W0603: Using the global statement (global-statement)

ruff

[11:55:00 | last: 21s] (  2) | ~/src/ruff
igozali@hostname $ cargo run -p ruff_cli -- check crates/ruff/resources/test/fixtures/pylint/global_statement.py --no-cache --select PLW0603
    Finished dev [unoptimized + debuginfo] target(s) in 0.29s
     Running `target/debug/ruff check crates/ruff/resources/test/fixtures/pylint/global_statement.py --no-cache --select PLW0603`
crates/ruff/resources/test/fixtures/pylint/global_statement.py:14:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:21:5: PLW0603 Using the global statement to update `sys` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:27:5: PLW0603 Using the global statement to update `namedtuple` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:33:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:40:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:47:5: PLW0603 Using the global statement to update `CONSTANT` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:57:5: PLW0603 Using the global statement to update `FUNC` is discouraged
crates/ruff/resources/test/fixtures/pylint/global_statement.py:67:5: PLW0603 Using the global statement to update `CLASS` is discouraged
Found 8 errors.

TODOs:

  • base impl
  • handle all cases in pylint
  • add doc

@igozali igozali force-pushed the plw0603-global-statement branch 2 times, most recently from 76e86ed to fdd689f Compare February 25, 2023 22:15
@igozali
Copy link
Contributor Author

igozali commented Feb 25, 2023

Wanted to get early feedback if possible 😄, but I think I'm still missing some violations in the original pylint test cases: https://github.com/PyCQA/pylint/blob/b04e690a429adb5a1b0f17b909d8a98149f22fea/tests/functional/g/globals.py

If the direction looks good, I'll do the import and del as well?

}

// PLW0603
pub fn global_statement(checker: &mut Checker, name: &str) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be a bit simpler. Above, I'd call pylint::rules::global_statement(self, target, id), then make this pub fn global_statement(checker: &mut Checker, expr: &Expr, name: &str), and then the body can just be:

checker.diagnostics.push(Diagnostic::new(
    GlobalStatement {
        name: name.to_string(),
    },
    Range::from_located(expr)
));

pylint::rules::global_statement(self, id);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think, instead, we should put this in the StmtKind::Global { names } => { ... } branch around line 341. That is: we should just trigger this rule when we declare the global.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I'm understanding correctly, what you want is for the behavior to be "warn whenever any global variable is declared", which is different from pylint's original definition of the W0603 rule:

Used when you use the "global" statement to update a global variable

Want to confirm if that's ok?

Copy link
Member

Choose a reason for hiding this comment

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

Ohh interesting, I totally missed that. Then I think you're on the right track here. The rule is maybe a little strange, since if you're not using global to update or otherwise mutate a variable, then the global is effectively useless anyway, right? Like why else define a global? But I generally prefer to maintain parity with upstream rules unless we have good reasons not to.

Copy link
Contributor Author

@igozali igozali Feb 26, 2023

Choose a reason for hiding this comment

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

Haha yeah I agree (would've loved to use your approach too if possible since it's way simpler), the original pylint rule feels a bit weird already, also there are 3 separate warnings that the user can configure but regardless, the range reported in all of them seems to always point to the global statement 😕

[09:01:35 | last: 0s] (  0) | /tmp
igozali@hostname $ bat main.py
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: main.py
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ def do_something():
   2   │     global a
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[09:01:39 | last: 0s] (  0) | /tmp
igozali@hostname $ pylint -d C --score=n main.py
************* Module main
main.py:2:4: W0602: Using global for 'a' but no assignment is done (global-variable-not-assigned)
[09:01:54 | last: 3s] (  0) | /tmp
igozali@hostname $ bat main.py
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: main.py
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ def do_something():
   2   │     global a
   3   │     a = 5
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[09:01:56 | last: 0s] (  0) | /tmp
igozali@hostname $ pylint -d C --score=n main.py
************* Module main
main.py:2:4: W0601: Global variable 'a' undefined at the module level (global-variable-undefined)
[09:02:20 | last: 3s] (  0) | /tmp
igozali@hostname $ bat main.py
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: main.py
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ a = 0
   2   │
   3   │ def do_something():
   4   │     global a
   5   │     a = 5
───────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

[09:02:22 | last: 0s] (  0) | /tmp
igozali@hostname $ pylint -d C --score=n main.py
************* Module main
main.py:4:4: W0603: Using the global statement (global-statement)

@igozali igozali force-pushed the plw0603-global-statement branch 2 times, most recently from cf5f238 to a8068d0 Compare February 26, 2023 18:54
@igozali
Copy link
Contributor Author

igozali commented Feb 26, 2023

Should be good for rereview now whenever convenient!

EDIT: Also added output comparison in PR description

@charliermarsh
Copy link
Member

Great, thanks! Will try to get to this today.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Feb 26, 2023
@charliermarsh charliermarsh enabled auto-merge (squash) February 26, 2023 23:38
@charliermarsh charliermarsh merged commit 4b5538f into astral-sh:main Feb 26, 2023
@charliermarsh
Copy link
Member

Thank you, nice PR!

@igozali
Copy link
Contributor Author

igozali commented Feb 27, 2023

Thanks for the guidance and maintaining an excellent linter!

@igozali igozali deleted the plw0603-global-statement branch February 27, 2023 15:58
bruxisma pushed a commit to ixm-one/pytest-cmake-presets that referenced this pull request Feb 27, 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.252` ->
`^0.0.253` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/compatibility-slim/0.0.252)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/confidence-slim/0.0.252)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.253`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.253)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.252...v0.0.253)

<!-- Release notes generated using configuration in .github/release.yml
at 386ca7c9a1bb7ebeb1457b605695c6a09e67092b -->

#### What's Changed

##### Rules

- \[`pyupgrade`] Avoid rewriting any PEP 604 runtime annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3217
- \[`pycodestyle`] Missing whitespace after keyword by
[@&#8203;carlosmiei](https://togithub.com/carlosmiei) in
[astral-sh/ruff#3225
- \[`pycodestyle`] trailing-whitespace, blank-line-contains-whitespace
(W291, W293) by [@&#8203;mknaw](https://togithub.com/mknaw) in
[astral-sh/ruff#3122
- \[`flake8-pyi`]: PYI009, PYI010, PYI021 by
[@&#8203;sbdchd](https://togithub.com/sbdchd) in
[astral-sh/ruff#3230
- \[`flake8-pyi`]: PYI011, PYI014 by
[@&#8203;sbdchd](https://togithub.com/sbdchd) in
[astral-sh/ruff#3238
- \[`flake8-django`] DJ003, DJ006, DJ007 by
[@&#8203;lkh42t](https://togithub.com/lkh42t) in
[astral-sh/ruff#3236
- \[`pylint`] Implement pylint's `else-if-used` rule (`PLR5501`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#3231
- \[`pylint`] W0603: global-statement by
[@&#8203;igozali](https://togithub.com/igozali) in
[astral-sh/ruff#3227
- \[`flake8-pie`] Unnecessary list comprehension, with autofix (PIE802)
by [@&#8203;matthewlloyd](https://togithub.com/matthewlloyd) in
[astral-sh/ruff#3149

##### Settings

- Allow ruff.toml file to be dot-prefixed (as .ruff.toml) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3221
- \[`pydocstyle`]: Implement `ignore-decorators` by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[astral-sh/ruff#3229

##### Bug Fixes

- Avoid suggesting 'is' for constant literals by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3146
- Omit non-.py\[i] files from module naming rules by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3153
- Bind star patterns in match statements by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3169
- Update RustPython to support \*tuple annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3178
- Use `writeln` with --show-settings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3180
- Avoid boolean-trap rules for ConfigParser get() methods by
[@&#8203;monosans](https://togithub.com/monosans) in
[astral-sh/ruff#3209
- Avoid flagging logging-too-few-args with no arguments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3220
- Expand the range of the COM812 autofix to include the preceding token
by [@&#8203;matthewlloyd](https://togithub.com/matthewlloyd) in
[astral-sh/ruff#3241
- Avoid flagging Pylint logging rules with starred arguments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3244
- Avoid flagging unfixable `TypedDict` and `NamedTuple` definitions by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3148
- Fix ExceptionGroup F821 false positive by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[astral-sh/ruff#3167
- Avoid autofixing some PT violations when comments are present by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3198
- Exclude globsets for --show-settings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3201
- \[`flake8-tidy-imports`] fix autofix for relative imports by
[@&#8203;sciyoshi](https://togithub.com/sciyoshi) in
[astral-sh/ruff#3197
- Fix Markdown errors in docs by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[astral-sh/ruff#3187
- Normalize treatment of aliased and unaliased imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3216
- Avoid EXE001 and EXE002 errors from stdin input by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3218
- \[bandit]: Do not treat "passed" as "password" for
`S105`/`S106`/`S107` by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[astral-sh/ruff#3222

#### New Contributors

- [@&#8203;mknaw](https://togithub.com/mknaw) made their first
contribution in
[astral-sh/ruff#3122
- [@&#8203;monosans](https://togithub.com/monosans) made their first
contribution in
[astral-sh/ruff#3209
- [@&#8203;lkh42t](https://togithub.com/lkh42t) made their first
contribution in
[astral-sh/ruff#3236
- [@&#8203;igozali](https://togithub.com/igozali) made their first
contribution in
[astral-sh/ruff#3227

**Full Changelog**:
astral-sh/ruff@v0.0.252...v0.0.253

</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:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNTIuNSIsInVwZGF0ZWRJblZlciI6IjM0LjE1Mi41In0=-->

Signed-off-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
renovate bot added a commit to allenporter/flux-local that referenced this pull request Mar 1, 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.247` ->
`==0.0.253` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/compatibility-slim/0.0.247)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.253/confidence-slim/0.0.247)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>charliermarsh/ruff</summary>

###
[`v0.0.253`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.253)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.252...v0.0.253)

<!-- Release notes generated using configuration in .github/release.yml
at 386ca7c9a1bb7ebeb1457b605695c6a09e67092b -->

#### What's Changed

##### Rules

- \[`pyupgrade`] Avoid rewriting any PEP 604 runtime annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3217
- \[`pycodestyle`] Missing whitespace after keyword by
[@&#8203;carlosmiei](https://togithub.com/carlosmiei) in
[astral-sh/ruff#3225
- \[`pycodestyle`] trailing-whitespace, blank-line-contains-whitespace
(W291, W293) by [@&#8203;mknaw](https://togithub.com/mknaw) in
[astral-sh/ruff#3122
- \[`flake8-pyi`]: PYI009, PYI010, PYI021 by
[@&#8203;sbdchd](https://togithub.com/sbdchd) in
[astral-sh/ruff#3230
- \[`flake8-pyi`]: PYI011, PYI014 by
[@&#8203;sbdchd](https://togithub.com/sbdchd) in
[astral-sh/ruff#3238
- \[`flake8-django`] DJ003, DJ006, DJ007 by
[@&#8203;lkh42t](https://togithub.com/lkh42t) in
[astral-sh/ruff#3236
- \[`pylint`] Implement pylint's `else-if-used` rule (`PLR5501`) by
[@&#8203;chanman3388](https://togithub.com/chanman3388) in
[astral-sh/ruff#3231
- \[`pylint`] W0603: global-statement by
[@&#8203;igozali](https://togithub.com/igozali) in
[astral-sh/ruff#3227
- \[`flake8-pie`] Unnecessary list comprehension, with autofix (PIE802)
by [@&#8203;matthewlloyd](https://togithub.com/matthewlloyd) in
[astral-sh/ruff#3149

##### Settings

- Allow ruff.toml file to be dot-prefixed (as .ruff.toml) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3221
- \[`pydocstyle`]: Implement `ignore-decorators` by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[astral-sh/ruff#3229

##### Bug Fixes

- Avoid suggesting 'is' for constant literals by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3146
- Omit non-.py\[i] files from module naming rules by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3153
- Bind star patterns in match statements by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3169
- Update RustPython to support \*tuple annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3178
- Use `writeln` with --show-settings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3180
- Avoid boolean-trap rules for ConfigParser get() methods by
[@&#8203;monosans](https://togithub.com/monosans) in
[astral-sh/ruff#3209
- Avoid flagging logging-too-few-args with no arguments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3220
- Expand the range of the COM812 autofix to include the preceding token
by [@&#8203;matthewlloyd](https://togithub.com/matthewlloyd) in
[astral-sh/ruff#3241
- Avoid flagging Pylint logging rules with starred arguments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3244
- Avoid flagging unfixable `TypedDict` and `NamedTuple` definitions by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3148
- Fix ExceptionGroup F821 false positive by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[astral-sh/ruff#3167
- Avoid autofixing some PT violations when comments are present by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3198
- Exclude globsets for --show-settings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3201
- \[`flake8-tidy-imports`] fix autofix for relative imports by
[@&#8203;sciyoshi](https://togithub.com/sciyoshi) in
[astral-sh/ruff#3197
- Fix Markdown errors in docs by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[astral-sh/ruff#3187
- Normalize treatment of aliased and unaliased imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3216
- Avoid EXE001 and EXE002 errors from stdin input by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3218
- \[bandit]: Do not treat "passed" as "password" for
`S105`/`S106`/`S107` by
[@&#8203;edgarrmondragon](https://togithub.com/edgarrmondragon) in
[astral-sh/ruff#3222

#### New Contributors

- [@&#8203;mknaw](https://togithub.com/mknaw) made their first
contribution in
[astral-sh/ruff#3122
- [@&#8203;monosans](https://togithub.com/monosans) made their first
contribution in
[astral-sh/ruff#3209
- [@&#8203;lkh42t](https://togithub.com/lkh42t) made their first
contribution in
[astral-sh/ruff#3236
- [@&#8203;igozali](https://togithub.com/igozali) made their first
contribution in
[astral-sh/ruff#3227

**Full Changelog**:
astral-sh/ruff@v0.0.252...v0.0.253

###
[`v0.0.252`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.252)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.251...v0.0.252)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Rules

- \[`pylint`] `redefined-loop-name` (`W2901`) by
[@&#8203;matthewlloyd](https://togithub.com/matthewlloyd) in
[astral-sh/ruff#3022
- \[`pylint`] ` logging-too-many-args ` (`E1205`) by
[@&#8203;md384](https://togithub.com/md384) in
[astral-sh/ruff#3084
- \[`pylint`] ` logging-too-few-args ` (`E1206`) by
[@&#8203;md384](https://togithub.com/md384) in
[astral-sh/ruff#3084

##### Bug Fixes

- Include file permissions in cache key by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3104
- Skip EXE001 and EXE002 rules on Windows by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3111
- Mark `typing.assert_never` as no return by
[@&#8203;bluetech](https://togithub.com/bluetech) in
[astral-sh/ruff#3121
- Use file-specific quote for C408 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3128
- Avoid match statement misidentification in token rules by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3129
- Upgrade RustPython to handle trailing commas in map patterns by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3130
- Avoid useless-else-on-loop for break within match by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3136
- Fix isort `no-lines-before` preceded by an empty section by
[@&#8203;bluetech](https://togithub.com/bluetech) in
[astral-sh/ruff#3139
- Support shell expansion for --config argument by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3107
- Fix =/== error in `ManualDictLookup` by
[@&#8203;Rupt](https://togithub.com/Rupt) in
[astral-sh/ruff#3117
- Include match in nested block check by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3137
- Upgrade RustPython to match new flattened exports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3141

#### New Contributors

- [@&#8203;md384](https://togithub.com/md384) made their first
contribution in
[astral-sh/ruff#3084
- [@&#8203;Rupt](https://togithub.com/Rupt) made their first
contribution in
[astral-sh/ruff#3117
- [@&#8203;marijncv](https://togithub.com/marijncv) made their first
contribution in
[astral-sh/ruff#3133

**Full Changelog**:
astral-sh/ruff@v0.0.251...v0.0.252

###
[`v0.0.251`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.251)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.250...v0.0.251)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Bug Fixes

- Create bindings for `MatchAs` patterns by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3098
- Avoid prefer-list-builtin for lambdas with `*args` or `**kwargs` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3102

**Full Changelog**:
astral-sh/ruff@v0.0.250...v0.0.251

###
[`v0.0.250`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.250)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.249...v0.0.250)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

**Ruff now supports all Python 3.10 and 3.11 language features**,
including:

- Structural Pattern Patching (`match` statements) ([PEP
634](https://peps.python.org/pep-0634/#class-patterns))
- Exception Groups (`except*` statements) ([PEP
654](https://peps.python.org/pep-0654/))

##### Rules

- \[`flake8-bugbear`] Add B029 (`except-with-empty-tuple`) from
flake8-bugbear by [@&#8203;carlosmiei](https://togithub.com/carlosmiei)
in
[astral-sh/ruff#3068
- \[`flake8-bugbear`] Add B032 (`unintentional-type-annotation`) from
flake8\_bugbear by [@&#8203;carlosmiei](https://togithub.com/carlosmiei)
in
[astral-sh/ruff#3085
- \[`tryceratops`]: Add TRY401 (`verbose-log-messages`) by
[@&#8203;colin99d](https://togithub.com/colin99d) in
[astral-sh/ruff#3036
- \[`flake8-simplify`]: Add SIM116 (`manual-dict-lookup`) by
[@&#8203;colin99d](https://togithub.com/colin99d) in
[astral-sh/ruff#2767

##### Features

- Add support for TryStar by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3089
- Add support for structural pattern matching by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3047

##### Bug Fixes

- \[`flake8-pytest`] Use LibCST to fix chained assertions by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3087
- \[`flake8-boolean-trap`] Avoid boolean-trap rules for positional-only
builtin calls by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3075
- \[`flake8-boolean-trap`] Ignore setters in flake8-boolean-trap by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3092
- \[`flake8-return`] Omit `while-True` loops from implicit return
enforcement by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3076

#### New Contributors

- [@&#8203;carlosmiei](https://togithub.com/carlosmiei) made their first
contribution in
[astral-sh/ruff#3068

**Full Changelog**:
astral-sh/ruff@v0.0.249...v0.0.250

###
[`v0.0.249`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.249)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.248...v0.0.249)

<!-- Release notes generated using configuration in .github/release.yml
at 4cfa350112a82fb631909fc555588f3da8ba5750 -->

#### What's Changed

##### Bug Fixes

- Relax constraints on pep8-naming module validation by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3043
- Do not autofix `E731` in class bodies by
[@&#8203;JoshKarpel](https://togithub.com/JoshKarpel) in
[astral-sh/ruff#3050
- Avoid assert() to assert statement conversion in expressions by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3062

#### New Contributors

- [@&#8203;matthewlloyd](https://togithub.com/matthewlloyd) made their
first contribution in
[astral-sh/ruff#3048
- [@&#8203;JoshKarpel](https://togithub.com/JoshKarpel) made their first
contribution in
[astral-sh/ruff#3050

**Full Changelog**:
astral-sh/ruff@v0.0.248...v0.0.249

###
[`v0.0.248`](https://togithub.com/charliermarsh/ruff/releases/tag/v0.0.248)

[Compare
Source](https://togithub.com/charliermarsh/ruff/compare/v0.0.247...v0.0.248)

<!-- Release notes generated using configuration in .github/release.yml
at main -->

#### What's Changed

##### Rules

- \[`numpy`] numpy-legacy-random by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2960
- \[`pycodestyle`] autofix useless semicolons by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#3001
- \[`pep8-naming`] Implement `flake8-module-naming` by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2855
- \[`flake8-self`] Ignore namedtuple methods in flake8-self by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2998
- \[`flake8-simplify`] Merge convert-loop-to-any & convert-loop-to-all
to reimplemented-builtin by
[@&#8203;not-my-profile](https://togithub.com/not-my-profile) in
[astral-sh/ruff#2903
- \[`ruff`] Add support for `ensure_future` for RUF006 by
[@&#8203;Lunarmagpie](https://togithub.com/Lunarmagpie) in
[astral-sh/ruff#2943
- \[`pylint`] error when `__init__` returns a value by
[@&#8203;r3m0t](https://togithub.com/r3m0t) in
[astral-sh/ruff#3007
- \[`flake8-pytest-style`] autofix for composite-assertion (PT018) by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2732
- \[`flake8-tidy-imports`] extend autofix of relative imports by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2990

##### Settings

- Add support for file-scoped `noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2978
- Add configuration option for C408 to allow dict calls with keyword
arguments. by [@&#8203;manueljacob](https://togithub.com/manueljacob) in
[astral-sh/ruff#2977
- feat(isort): Implement isort.force_to_top by
[@&#8203;spaceone](https://togithub.com/spaceone) in
[astral-sh/ruff#2877

##### Bug Fixes

- Fix add-required-import with multi-line offsets by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2946
- Support positional messages in assertion rewrites by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3002
- Avoid false-positives for break in with by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#3032
- Avoid trying to fix implicit returns with control flow by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2962
- Handle non-from **future** imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2974
- Enforce D403 on methods by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2992
- Avoid zero-indexed column for IOError by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#2995
- Fix for F541 unescape f-string by
[@&#8203;sbrugman](https://togithub.com/sbrugman) in
[astral-sh/ruff#2971
- Avoid raising `B027` violations in `.pyi` files by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[astral-sh/ruff#3016

#### New Contributors

- [@&#8203;Lunarmagpie](https://togithub.com/Lunarmagpie) made their
first contribution in
[astral-sh/ruff#2943
- [@&#8203;manueljacob](https://togithub.com/manueljacob) made their
first contribution in
[astral-sh/ruff#2966
- [@&#8203;mwtoews](https://togithub.com/mwtoews) made their first
contribution in
[astral-sh/ruff#2973
- [@&#8203;ortem](https://togithub.com/ortem) made their first
contribution in
[astral-sh/ruff#2976
- [@&#8203;thatlittleboy](https://togithub.com/thatlittleboy) made their
first contribution in
[astral-sh/ruff#3027
- [@&#8203;r3m0t](https://togithub.com/r3m0t) made their first
contribution in
[astral-sh/ruff#3007

**Full Changelog**:
astral-sh/ruff@v0.0.247...v0.0.248

</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:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM0LjE1My4yIn0=-->

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.

None yet

2 participants