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

Add RUF016: Detection of invalid index types #5602

Merged
merged 21 commits into from
Jul 12, 2023
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 7, 2023

Detects invalid types for tuple, list, bytes, string indices.

For example, the following will raise a TypeError at runtime and when imported Python will display a SyntaxWarning

var = [1, 2, 3]["x"]
example.py:1: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  var = [1, 2, 3]["x"]
Traceback (most recent call last):
  File "example.py", line 1, in <module>
    var = [1, 2, 3]["x"]
          ~~~~~~~~~^^^^^
TypeError: list indices must be integers or slices, not str

Previously, Ruff would not report the invalid syntax but now a violation will be reported. This does not apply to cases where a variable, call, or complex expression is used in the index — detection is roughly limited to static definitions, which matches Python's warnings.

❯ ./target/debug/ruff example.py --select RUF015 --show-source --no-cache
example.py:1:17: RUF015 Indexed access to type `list` uses type `str` instead of an integer or slice.
  |
1 | var = [1, 2, 3]["x"]
  |                 ^^^ RUF015
  |

Closes #5082
xref python/cpython@ffff144

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                    pr
-----                                      ----                                    --
formatter/large/dataset.py                 1.01      8.6±0.46ms     4.8 MB/sec     1.00      8.4±0.37ms     4.8 MB/sec
formatter/numpy/ctypeslib.py               1.00  1981.2±115.85µs     8.4 MB/sec    1.01  1997.7±147.35µs     8.3 MB/sec
formatter/numpy/globals.py                 1.01   227.4±14.01µs    13.0 MB/sec     1.00   225.5±13.82µs    13.1 MB/sec
formatter/pydantic/types.py                1.00      4.2±0.19ms     6.1 MB/sec     1.02      4.3±0.21ms     6.0 MB/sec
linter/all-rules/large/dataset.py          1.00     14.9±0.62ms     2.7 MB/sec     1.01     15.0±0.53ms     2.7 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.02      3.7±0.15ms     4.5 MB/sec     1.00      3.6±0.15ms     4.6 MB/sec
linter/all-rules/numpy/globals.py          1.00   471.5±37.62µs     6.3 MB/sec     1.02   478.9±25.68µs     6.2 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.7±0.37ms     3.8 MB/sec     1.00      6.6±0.29ms     3.8 MB/sec
linter/default-rules/large/dataset.py      1.00      7.2±0.29ms     5.6 MB/sec     1.00      7.2±0.24ms     5.6 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1583.3±67.33µs    10.5 MB/sec     1.02  1608.8±84.20µs    10.3 MB/sec
linter/default-rules/numpy/globals.py      1.04   191.8±16.00µs    15.4 MB/sec     1.00    184.2±9.93µs    16.0 MB/sec
linter/default-rules/pydantic/types.py     1.01      3.3±0.14ms     7.7 MB/sec     1.00      3.3±0.19ms     7.7 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      9.5±0.06ms     4.3 MB/sec    1.00      9.5±0.05ms     4.3 MB/sec
formatter/numpy/ctypeslib.py               1.00      2.1±0.01ms     7.9 MB/sec    1.02      2.2±0.09ms     7.7 MB/sec
formatter/numpy/globals.py                 1.00    229.7±5.18µs    12.8 MB/sec    1.01    232.4±7.65µs    12.7 MB/sec
formatter/pydantic/types.py                1.00      4.7±0.06ms     5.4 MB/sec    1.00      4.7±0.05ms     5.4 MB/sec
linter/all-rules/large/dataset.py          1.02     15.9±0.15ms     2.6 MB/sec    1.00     15.6±0.11ms     2.6 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      4.2±0.04ms     4.0 MB/sec    1.00      4.1±0.03ms     4.0 MB/sec
linter/all-rules/numpy/globals.py          1.00   427.6±11.45µs     6.9 MB/sec    1.00    426.3±4.69µs     6.9 MB/sec
linter/all-rules/pydantic/types.py         1.02      7.2±0.05ms     3.6 MB/sec    1.00      7.1±0.07ms     3.6 MB/sec
linter/default-rules/large/dataset.py      1.02      8.3±0.05ms     4.9 MB/sec    1.00      8.1±0.06ms     5.0 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1672.7±12.11µs    10.0 MB/sec    1.00  1668.8±18.43µs    10.0 MB/sec
linter/default-rules/numpy/globals.py      1.00    180.7±1.73µs    16.3 MB/sec    1.00    180.5±4.26µs    16.3 MB/sec
linter/default-rules/pydantic/types.py     1.01      3.7±0.02ms     7.0 MB/sec    1.00      3.6±0.02ms     7.1 MB/sec

@zanieb
Copy link
Member Author

zanieb commented Jul 10, 2023

In a comparison with Python's syntax warnings, we use a different message format and perform additional validation of the types used in slices.

❯ python crates/ruff/resources/test/fixtures/ruff/RUF015.py     
RUF015.py:20: SyntaxWarning: str indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:21: SyntaxWarning: str indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:24: SyntaxWarning: bytes indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:27: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:28: SyntaxWarning: tuple indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:31: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:34: SyntaxWarning: str indices must be integers or slices, not tuple; perhaps you missed a comma?
RUF015.py:37: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
RUF015.py:40: SyntaxWarning: list indices must be integers or slices, not float; perhaps you missed a comma?
RUF015.py:43: SyntaxWarning: list indices must be integers or slices, not dict; perhaps you missed a comma?
RUF015.py:46: SyntaxWarning: list indices must be integers or slices, not dict; perhaps you missed a comma?
RUF015.py:49: SyntaxWarning: list indices must be integers or slices, not tuple; perhaps you missed a comma?
RUF015.py:52: SyntaxWarning: list indices must be integers or slices, not list; perhaps you missed a comma?
RUF015.py:55: SyntaxWarning: list indices must be integers or slices, not set; perhaps you missed a comma?
RUF015.py:58: SyntaxWarning: list indices must be integers or slices, not bytes; perhaps you missed a comma?
RUF015.py:76: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
❯ ./target/debug/ruff check --select RUF015 crates/ruff/resources/test/fixtures/ruff/RUF015.py
RUF015.py:20:13: RUF015 Indexed access to type `str` uses type `str` instead of an integer or slice.
RUF015.py:21:14: RUF015 Indexed access to type `str` uses type `str` instead of an integer or slice.
RUF015.py:24:14: RUF015 Indexed access to type `bytes` uses type `str` instead of an integer or slice.
RUF015.py:27:17: RUF015 Indexed access to type `list` uses type `str` instead of an integer or slice.
RUF015.py:28:17: RUF015 Indexed access to type `tuple` uses type `str` instead of an integer or slice.
RUF015.py:31:30: RUF015 Indexed access to type `list comprehension` uses type `str` instead of an integer or slice.
RUF015.py:34:13: RUF015 Indexed access to type `str` uses type `tuple` instead of an integer or slice.
RUF015.py:37:14: RUF015 Indexed access to type `list` uses type `str` instead of an integer or slice.
RUF015.py:40:14: RUF015 Indexed access to type `list` uses type `float` instead of an integer or slice.
RUF015.py:43:14: RUF015 Indexed access to type `list` uses type `dict` instead of an integer or slice.
RUF015.py:46:14: RUF015 Indexed access to type `list` uses type `dict comprehension` instead of an integer or slice.
RUF015.py:49:14: RUF015 Indexed access to type `list` uses type `tuple` instead of an integer or slice.
RUF015.py:52:14: RUF015 Indexed access to type `list` uses type `list comprehension` instead of an integer or slice.
RUF015.py:55:14: RUF015 Indexed access to type `list` uses type `set` instead of an integer or slice.
RUF015.py:58:14: RUF015 Indexed access to type `list` uses type `bytes` instead of an integer or slice.
RUF015.py:61:17: RUF015 Slice in indexed access to type `list` uses type `str` as bound instead of an integer.
RUF015.py:62:17: RUF015 Slice in indexed access to type `list` uses type `str` as bound instead of an integer.
RUF015.py:63:17: RUF015 Slice in indexed access to type `list` uses type `float` as bound instead of an integer.
RUF015.py:64:17: RUF015 Slice in indexed access to type `list` uses type `set` as bound instead of an integer.
RUF015.py:67:19: RUF015 Slice in indexed access to type `list` uses type `str` as bound instead of an integer.
RUF015.py:68:19: RUF015 Slice in indexed access to type `list` uses type `str` as bound instead of an integer.
RUF015.py:69:19: RUF015 Slice in indexed access to type `list` uses type `float` as bound instead of an integer.
RUF015.py:70:19: RUF015 Slice in indexed access to type `list` uses type `set` as bound instead of an integer.
RUF015.py:73:17: RUF015 Slice in indexed access to type `list` uses type `str` as bound instead of an integer.
RUF015.py:73:21: RUF015 Slice in indexed access to type `list` uses type `str` as bound instead of an integer.
RUF015.py:76:17: RUF015 Indexed access to type `list` uses type `str` instead of an integer or slice.

I've ensured that each of the slice cases raises an error at runtime

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 3, in <module>
    var = [1, 2, 3]["x":2]
          ~~~~~~~~~^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 4, in <module>
    var = [1, 2, 3][f"x":2]
          ~~~~~~~~~^^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 5, in <module>
    var = [1, 2, 3][1.2:2]
          ~~~~~~~~~^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 6, in <module>
    var = [1, 2, 3][{"x"}:2]
          ~~~~~~~~~^^^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 9, in <module>
    var = [1, 2, 3][0:"x"]
          ~~~~~~~~~^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 10, in <module>
    var = [1, 2, 3][0:f"x"]
          ~~~~~~~~~^^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

Traceback (most recent call last):
  File "/Users/mz/eng/src/charliermarsh/ruff/example.py", line 11, in <module>
    var = [1, 2, 3][0:1.2]
          ~~~~~~~~~^^^^^^^
TypeError: slice indices must be integers or None or have an __index__ method

@zanieb zanieb marked this pull request as ready for review July 10, 2023 16:17
crates/ruff/src/rules/ruff/rules/invalid_index_type.rs Outdated Show resolved Hide resolved
Comment on lines 151 to 152
// If it's anything else, it's too hard to tell if it's a violation
_ => (),
Copy link
Member

Choose a reason for hiding this comment

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

Should we list the expressions here to force a compile error when a new expression was added.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. Unless new literal types are introduced, a new expression is unlikely to be detectable by this rule as a violation.

crates/ruff/src/rules/ruff/rules/invalid_index_type.rs Outdated Show resolved Hide resolved
Comment on lines 75 to 77
// The types supported by this rule should always be checkable
let value_type = CheckableExprType::try_from(&value)
.expect("Expected indexed expression to be a checkable type.");
Copy link
Member Author

Choose a reason for hiding this comment

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

@charliermarsh I retained this expect because I'd rather not silently return in this case. A developer has broken this rule if the type is not checkable.

@zanieb zanieb changed the title Add RUF015: Detection of invalid index types Add RUF016: Detection of invalid index types Jul 11, 2023
@zanieb
Copy link
Member Author

zanieb commented Jul 11, 2023

Note I had to rebase this due to conflict with #5549 which took the RUF015 code — some of the commits will not pass tests anymore.

subscript: &Expr,
subscript: &ExprSubscript,
Copy link
Member Author

Choose a reason for hiding this comment

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

I narrowed this to match the pattern used in InvalidIndexType

crates/ruff/src/rules/ruff/rules/invalid_index_type.rs Outdated Show resolved Hide resolved

// The value types supported by this rule should always be checkable
let value_type = CheckableExprType::try_from(value)
.expect("Expected indexed expression to be a checkable type.");
Copy link
Member

Choose a reason for hiding this comment

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

To me it would be a bit more natural to do this before the if !matches (like let Some(value_type) = ... else { return; };), then have an if !matches(value_type, CheckableExprType::List | ...) to enforce the further narrowing. That way the expect is unnecessary as the condition is impossible. But it's not blocking.

Copy link
Member Author

@zanieb zanieb Jul 12, 2023

Choose a reason for hiding this comment

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

I did this before then moved it back to an expect, I feel like it confuses the logic of the rule. Like...

If the value is a list, byte, string, or tuple then we want to enforce this rule.

To display a violation, we happen to use CheckableExprType to generate a type name for the value. However, this is just for display purposes not a limitation of the rule itself.

If someone were to extend the rule to apply to a new type, e.g. byte arrays, I would not expect this function to exit early because there is not an implementation for displaying the type name. In this case, the expect would point a developer to the next step in their implementation.

🤷‍♀️ it does feel like a subtle stylistic choice in the end — maybe you shouldn't have sent me that BurntSushi article 😝

I'm kind of curious to see what lessons I learn from making my own stylistic choices but I'm happy to follow precedent for the project too!

Copy link
Member

Choose a reason for hiding this comment

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

This makes sense. I'd say run with what you have here! I tend to be pretty defensive around expect and unwrap (which are ~equivalent) because they're not recoverable in any way, so e.g. if we shipped a release that had an oversight here, Ruff would bail entirely on files that hit this codepath.

The "right" answer here may be to extend CheckableExprType to instead implement all expression types (so it doesn't return Option), or perhaps to use a debug assertion so that we see this failure in debug builds but fail silently in releases. But it's also ok for now, we know that it's a superset of expressions on the match anyway. (And we're obviously overdoing it on this one point just for educational / discussion purposes, it's not a sticking point in practice :))

Copy link
Member Author

Choose a reason for hiding this comment

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

or perhaps to use a debug assertion so that we see this failure in debug builds but fail silently in releases.

I'm pretty happy with that as an approach.

Although... I'd also want a user to report a failure here because it's a bug in Ruff. I guess it's a matter of if we want to panic and make the rule entirely unusable for their code or fail silently and hope they notice that the rule isn't raising a violation. I can understand preferring the second as a safer user experience :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted debug_panic!(...) but I guess debug_assert!(false, ...) will do e058e24

Copy link
Member

Choose a reason for hiding this comment

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

I'm happy with whatever! If it were me on a desert island, I guess I'd write something like let Some(value_type) = CheckableExprType::try_from(value) else { return; }; but I'm not convinced that's the best option. This looks good to me.

(Again just to complete the picture, I think if we hit a panic here, the behavior the user would see is that we'd throw up a message asking them to file an issue and wouldn't print any violations for the failing file, but would print out violations for all other files as usual.)

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Looks great :)

@zanieb zanieb merged commit 0666add into astral-sh:main Jul 12, 2023
16 checks passed
renovate bot added a commit to ixm-one/pytest-cmake-presets that referenced this pull request Jul 12, 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://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `^0.0.277`
-> `^0.0.278` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/compatibility-slim/0.0.277)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/confidence-slim/0.0.277)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.278`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.278)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.277...v0.0.278)

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

#### What's Changed

##### Rules

- \[`pylint`] Implement `typevar-bivariance` (`PLC0131`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5517
- \[`flake8-pyi`] Implement `unnecessary-literal-union` (`PYI030`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5570
- \[`pylint`] Implement `type-name-incorrect-variance` (`PLC0105`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5651
- \[`ruff`] Implement `unnecessary-list-allocation-for-first-element`
(`RUF015`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5549
- \[`flake8-bugbear`] Implement `re-sub-positional-args` (`B034`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5669
- \[`ruff`] Implement `invalid-index-type` (`RUF016`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5602

##### Settings

- \[`isort`] Add `--case-sensitive` flag by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5539
- \[`isort`] Support globbing in `isort` options by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5473

##### Bug Fixes

- Support autofix for some multiline `str.format` calls by
[@&#8203;harupy](https://togithub.com/harupy) in
[astral-sh/ruff#5638
- Avoid triggering `unnecessary-map` (`C417`) for late-bound lambdas by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5520
- Avoid triggering DTZ001-006 when using `.astimezone()` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5524
- Enable attribute lookups via semantic model by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5536
- Avoid syntax errors when rewriting str(dict) in f-strings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5538
- Differentiate between runtime and typing-time annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5575
- Only run pyproject.toml lint rules when enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5578
- Refactor isort directive skips to use iterators by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5623
- Allow descriptor instantiations in dataclass fields by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5537
- Refactor `noqa` directive parsing away from regex-based implementation
by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5554
- Emit warnings for invalid `# noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5571
- Support individual codes on `# flake8: noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5618
- Add `tkinter` import convention by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5626
- Avoid `PERF401` if conditional depends on list var by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5603
- Fix typo in complex-if-statement-in-stub message by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5635
- Make TRY301 trigger only if a `raise` throws a caught exception by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5455
- Skip flake8-future-annotations checks in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5652
- Always allow PEP 585 and PEP 604 rewrites in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5653
- Add support for `Union` declarations without `|` to PYI016 by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5598
- Ignore `_name_` and `_value_` accesses in `flake8-self` rules by
[@&#8203;monosans](https://togithub.com/monosans) in
[astral-sh/ruff#5663
- Refactor `repeated_keys()` to use `ComparableExpr` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5696

#### New Contributors

- [@&#8203;karosis88](https://togithub.com/karosis88) made their first
contribution in
[astral-sh/ruff#5560
- [@&#8203;petermattia](https://togithub.com/petermattia) made their
first contribution in
[astral-sh/ruff#5579
-
[@&#8203;DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos)
made their first contribution in
[astral-sh/ruff#5607

**Full Changelog**:
astral-sh/ruff@v0.0.277...v0.0.278

</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://developer.mend.io/github/ixm-one/pytest-cmake-presets).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
jankatins added a commit to jankatins/pr-workflow-example that referenced this pull request Jul 12, 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://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `0.0.277`
-> `0.0.278` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/compatibility-slim/0.0.277)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/confidence-slim/0.0.277)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.278`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.278)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.277...v0.0.278)

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

#### What's Changed

##### Rules

- \[`pylint`] Implement `typevar-bivariance` (`PLC0131`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5517
- \[`flake8-pyi`] Implement `unnecessary-literal-union` (`PYI030`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5570
- \[`pylint`] Implement `type-name-incorrect-variance` (`PLC0105`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5651
- \[`ruff`] Implement `unnecessary-list-allocation-for-first-element`
(`RUF015`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5549
- \[`flake8-bugbear`] Implement `re-sub-positional-args` (`B034`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5669
- \[`ruff`] Implement `invalid-index-type` (`RUF016`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5602

##### Settings

- \[`isort`] Add `--case-sensitive` flag by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5539
- \[`isort`] Support globbing in `isort` options by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5473

##### Bug Fixes

- Support autofix for some multiline `str.format` calls by
[@&#8203;harupy](https://togithub.com/harupy) in
[astral-sh/ruff#5638
- Avoid triggering `unnecessary-map` (`C417`) for late-bound lambdas by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5520
- Avoid triggering DTZ001-006 when using `.astimezone()` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5524
- Enable attribute lookups via semantic model by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5536
- Avoid syntax errors when rewriting str(dict) in f-strings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5538
- Differentiate between runtime and typing-time annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5575
- Only run pyproject.toml lint rules when enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5578
- Refactor isort directive skips to use iterators by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5623
- Allow descriptor instantiations in dataclass fields by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5537
- Refactor `noqa` directive parsing away from regex-based implementation
by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5554
- Emit warnings for invalid `# noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5571
- Support individual codes on `# flake8: noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5618
- Add `tkinter` import convention by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5626
- Avoid `PERF401` if conditional depends on list var by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5603
- Fix typo in complex-if-statement-in-stub message by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5635
- Make TRY301 trigger only if a `raise` throws a caught exception by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5455
- Skip flake8-future-annotations checks in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5652
- Always allow PEP 585 and PEP 604 rewrites in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5653
- Add support for `Union` declarations without `|` to PYI016 by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5598
- Ignore `_name_` and `_value_` accesses in `flake8-self` rules by
[@&#8203;monosans](https://togithub.com/monosans) in
[astral-sh/ruff#5663
- Refactor `repeated_keys()` to use `ComparableExpr` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5696

#### New Contributors

- [@&#8203;karosis88](https://togithub.com/karosis88) made their first
contribution in
[astral-sh/ruff#5560
- [@&#8203;petermattia](https://togithub.com/petermattia) made their
first contribution in
[astral-sh/ruff#5579
-
[@&#8203;DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos)
made their first contribution in
[astral-sh/ruff#5607

**Full Changelog**:
astral-sh/ruff@v0.0.277...v0.0.278

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **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://developer.mend.io/github/jankatins/pr-workflow-example).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->
renovate bot added a commit to allenporter/pyrainbird that referenced this pull request Jul 14, 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://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `==0.0.277`
-> `==0.0.278` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/compatibility-slim/0.0.277)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/confidence-slim/0.0.277)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.278`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.278)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.277...v0.0.278)

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

See the [release blog post](https://astral.sh/blog/ruff-v0.0.278) for
more, including detailed descriptions of any newly added rules.

#### What's Changed

##### Rules

- \[`pylint`] Implement `typevar-bivariance` (`PLC0131`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5517
- \[`flake8-pyi`] Implement `unnecessary-literal-union` (`PYI030`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5570
- \[`pylint`] Implement `type-name-incorrect-variance` (`PLC0105`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5651
- \[`ruff`] Implement `unnecessary-list-allocation-for-first-element`
(`RUF015`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5549
- \[`flake8-bugbear`] Implement `re-sub-positional-args` (`B034`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5669
- \[`ruff`] Implement `invalid-index-type` (`RUF016`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5602

##### Settings

- \[`isort`] Add `--case-sensitive` flag by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5539
- \[`isort`] Support globbing in `isort` options by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5473

##### Bug Fixes

- Support autofix for some multiline `str.format` calls by
[@&#8203;harupy](https://togithub.com/harupy) in
[astral-sh/ruff#5638
- Avoid triggering `unnecessary-map` (`C417`) for late-bound lambdas by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5520
- Avoid triggering DTZ001-006 when using `.astimezone()` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5524
- Enable attribute lookups via semantic model by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5536
- Avoid syntax errors when rewriting str(dict) in f-strings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5538
- Differentiate between runtime and typing-time annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5575
- Only run pyproject.toml lint rules when enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5578
- Refactor isort directive skips to use iterators by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5623
- Allow descriptor instantiations in dataclass fields by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5537
- Refactor `noqa` directive parsing away from regex-based implementation
by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5554
- Emit warnings for invalid `# noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5571
- Support individual codes on `# flake8: noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5618
- Add `tkinter` import convention by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5626
- Avoid `PERF401` if conditional depends on list var by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5603
- Fix typo in complex-if-statement-in-stub message by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5635
- Make TRY301 trigger only if a `raise` throws a caught exception by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5455
- Skip flake8-future-annotations checks in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5652
- Always allow PEP 585 and PEP 604 rewrites in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5653
- Add support for `Union` declarations without `|` to PYI016 by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5598
- Ignore `_name_` and `_value_` accesses in `flake8-self` rules by
[@&#8203;monosans](https://togithub.com/monosans) in
[astral-sh/ruff#5663
- Refactor `repeated_keys()` to use `ComparableExpr` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5696

#### New Contributors

- [@&#8203;karosis88](https://togithub.com/karosis88) made their first
contribution in
[astral-sh/ruff#5560
- [@&#8203;petermattia](https://togithub.com/petermattia) made their
first contribution in
[astral-sh/ruff#5579
-
[@&#8203;DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos)
made their first contribution in
[astral-sh/ruff#5607

**Full Changelog**:
astral-sh/ruff@v0.0.277...v0.0.278

</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://developer.mend.io/github/allenporter/pyrainbird).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

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 Jul 15, 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://beta.ruff.rs/docs)
([source](https://togithub.com/astral-sh/ruff),
[changelog](https://togithub.com/astral-sh/ruff/releases)) | `==0.0.275`
-> `==0.0.278` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/compatibility-slim/0.0.275)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.278/confidence-slim/0.0.275)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.0.278`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.278)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.277...v0.0.278)

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

See the [release blog post](https://astral.sh/blog/ruff-v0.0.278) for
more, including detailed descriptions of any newly added rules.

#### What's Changed

##### Rules

- \[`pylint`] Implement `typevar-bivariance` (`PLC0131`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5517
- \[`flake8-pyi`] Implement `unnecessary-literal-union` (`PYI030`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5570
- \[`pylint`] Implement `type-name-incorrect-variance` (`PLC0105`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5651
- \[`ruff`] Implement `unnecessary-list-allocation-for-first-element`
(`RUF015`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5549
- \[`flake8-bugbear`] Implement `re-sub-positional-args` (`B034`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5669
- \[`ruff`] Implement `invalid-index-type` (`RUF016`) by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5602

##### Settings

- \[`isort`] Add `--case-sensitive` flag by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5539
- \[`isort`] Support globbing in `isort` options by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5473

##### Bug Fixes

- Support autofix for some multiline `str.format` calls by
[@&#8203;harupy](https://togithub.com/harupy) in
[astral-sh/ruff#5638
- Avoid triggering `unnecessary-map` (`C417`) for late-bound lambdas by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5520
- Avoid triggering DTZ001-006 when using `.astimezone()` by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5524
- Enable attribute lookups via semantic model by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5536
- Avoid syntax errors when rewriting str(dict) in f-strings by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5538
- Differentiate between runtime and typing-time annotations by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5575
- Only run pyproject.toml lint rules when enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5578
- Refactor isort directive skips to use iterators by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5623
- Allow descriptor instantiations in dataclass fields by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5537
- Refactor `noqa` directive parsing away from regex-based implementation
by [@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5554
- Emit warnings for invalid `# noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5571
- Support individual codes on `# flake8: noqa` directives by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5618
- Add `tkinter` import convention by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5626
- Avoid `PERF401` if conditional depends on list var by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5603
- Fix typo in complex-if-statement-in-stub message by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5635
- Make TRY301 trigger only if a `raise` throws a caught exception by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5455
- Skip flake8-future-annotations checks in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5652
- Always allow PEP 585 and PEP 604 rewrites in stub files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5653
- Add support for `Union` declarations without `|` to PYI016 by
[@&#8203;zanieb](https://togithub.com/zanieb) in
[astral-sh/ruff#5598
- Ignore `_name_` and `_value_` accesses in `flake8-self` rules by
[@&#8203;monosans](https://togithub.com/monosans) in
[astral-sh/ruff#5663
- Refactor `repeated_keys()` to use `ComparableExpr` by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5696

#### New Contributors

- [@&#8203;karosis88](https://togithub.com/karosis88) made their first
contribution in
[astral-sh/ruff#5560
- [@&#8203;petermattia](https://togithub.com/petermattia) made their
first contribution in
[astral-sh/ruff#5579
-
[@&#8203;DimitriPapadopoulos](https://togithub.com/DimitriPapadopoulos)
made their first contribution in
[astral-sh/ruff#5607

**Full Changelog**:
astral-sh/ruff@v0.0.277...v0.0.278

###
[`v0.0.277`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.277)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.276...v0.0.277)

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

#### What's Changed

##### Breaking Changes

- Add .ipynb_checkpoints, .pyenv, .pytest_cache, and .vscode to default
excludes by [@&#8203;charliermarsh](https://togithub.com/charliermarsh)
in
[astral-sh/ruff#5513

##### Rules

- \[`pylint`] Implement Pylint `typevar-name-mismatch` (`C0132`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5501

##### Settings

- Add `ruff rule --all` subcommand (with JSON output) by
[@&#8203;akx](https://togithub.com/akx) in
[astral-sh/ruff#5059

##### Bug Fixes

- Fix eval detection for suspicious-eval-usage by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5506
- Avoid PERF rules for iteration-dependent assignments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5508
- Avoid returning first-match for rule prefixes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5511

**Full Changelog**:
astral-sh/ruff@v0.0.276...v0.0.277

###
[`v0.0.276`](https://togithub.com/astral-sh/ruff/releases/tag/v0.0.276)

[Compare
Source](https://togithub.com/astral-sh/ruff/compare/v0.0.275...v0.0.276)

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

See the [release blog post](https://astral.sh/blog/ruff-v0.0.276) for
more, including detailed descriptions of any newly added rules.

#### What's Changed

Highlights include: experimental support for linting Jupyter Notebooks.

To opt-in to linting Jupyter Notebook files, add the `*.ipynb` pattern
to your [`include`](settings.md#include)
setting, like so:

```toml
[tool.ruff]

### Allow Ruff to discover `*.ipynb` files.
include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]
```

This will prompt Ruff to discover Jupyter Notebook files in any
specified directories, and lint them
accordingly.

Jupyter Notebook support is currently opt-in and experimental. We'd love
your help testing it out.
Have feedback? Run into issues? [Let us
know!](https://togithub.com/astral-sh/ruff/issues/new)

##### New Rules

- \[`flake8-pyi`] Implement `PYI002`, `PYI003`, `PYI004`, `PYI005` by
[@&#8203;density](https://togithub.com/density) in
[astral-sh/ruff#5457
- \[`numpy`] Implement `numpy-deprecated-function` (`NPY003`) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5468
- \[`perflint`] Implement `unnecessary-list-cast` (`PERF101`) by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5121
- \[`perflint`] Implement `try-except-in-loop` (`PERF203`) by
[@&#8203;evanrittenhouse](https://togithub.com/evanrittenhouse) in
[astral-sh/ruff#5166
- \[`perflint`] Implement `manual-list-comprehension` (`PERF401`) and
`manual-list-copy` (`PERF402`) rules by
[@&#8203;qdegraaf](https://togithub.com/qdegraaf) in
[astral-sh/ruff#5298
- \[`pylint`] Implement Pylint `single-string-used-for-slots` (`C0205`)
as `single-string-slots` (`PLC0205`) by
[@&#8203;tjkuson](https://togithub.com/tjkuson) in
[astral-sh/ruff#5399

##### Jupyter

- Experimental release for Jupyter notebook integration by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5363
- Enable --watch for Jupyter notebooks by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5394
- Consider Jupyter index for code frames (`--show-source`) by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5402
- fixup! Consider Jupyter index for code frames (`--show-source`)
([#&#8203;5402](https://togithub.com/astral-sh/ruff/issues/5402)) by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5414

##### Settings

- \[`pyupgrade`] Restore the `keep-runtime-typing` setting by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5470
- Add `PythonVersion::Py312` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5316

##### Bug Fixes

- Support `pydantic.BaseSettings` in `mutable-class-default` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5312
- Allow `__slots__` assignments in `mutable-class-default` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5314
- Avoid syntax errors when removing f-string prefixes by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5319
- Ignore unpacking in `iteration-over-set` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5392
- Replace same length equal line with dash line in D407 by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5383
- Exclude docstrings from PYI053 by
[@&#8203;intgr](https://togithub.com/intgr) in
[astral-sh/ruff#5405
- Use "manual" fixability for E731 in shadowed context by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5430
- Detect consecutive, non-newline-delimited NumPy sections by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5467
- Fix `unnecessary-encode-utf8` to fix `encode` on parenthesized strings
correctly by [@&#8203;harupy](https://togithub.com/harupy) in
[astral-sh/ruff#5478
- Allow `Final` assignments in stubs by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5490
- Respect `abc` decorators when classifying function types by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5315
- Allow `@Author` format for "Missing Author" rule in `flake8-todos` by
[@&#8203;mayrholu](https://togithub.com/mayrholu) in
[astral-sh/ruff#4903
- Ignore type aliases for RUF013 by
[@&#8203;dhruvmanila](https://togithub.com/dhruvmanila) in
[astral-sh/ruff#5344
- Change W605 autofix to use raw strings if possible by
[@&#8203;hauntsaninja](https://togithub.com/hauntsaninja) in
[astral-sh/ruff#5352
- Add space when migrating to raw string by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5358
- Update the `invalid-escape-sequence` rule by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5359
- Include BaseException in B017 rule by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5466
- \[`flake8-django`] Skip duplicate violations in `DJ012` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[astral-sh/ruff#5469

#### New Contributors

- [@&#8203;mayrholu](https://togithub.com/mayrholu) made their first
contribution in
[astral-sh/ruff#4903
- [@&#8203;hauntsaninja](https://togithub.com/hauntsaninja) made their
first contribution in
[astral-sh/ruff#5352
- [@&#8203;ethunk](https://togithub.com/ethunk) made their first
contribution in
[astral-sh/ruff#5397
- [@&#8203;LouisDISPA](https://togithub.com/LouisDISPA) made their first
contribution in
[astral-sh/ruff#5475

**Full Changelog**:
astral-sh/ruff@v0.0.275...v0.0.276

</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://developer.mend.io/github/allenporter/flux-local).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTkuNyIsInVwZGF0ZWRJblZlciI6IjM2LjUuMyIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
konstin pushed a commit that referenced this pull request Jul 19, 2023
Detects invalid types for tuple, list, bytes, string indices.

For example, the following will raise a `TypeError` at runtime and when
imported Python will display a `SyntaxWarning`

```python
var = [1, 2, 3]["x"]
```

```
example.py:1: SyntaxWarning: list indices must be integers or slices, not str; perhaps you missed a comma?
  var = [1, 2, 3]["x"]
Traceback (most recent call last):
  File "example.py", line 1, in <module>
    var = [1, 2, 3]["x"]
          ~~~~~~~~~^^^^^
TypeError: list indices must be integers or slices, not str
```

Previously, Ruff would not report the invalid syntax but now a violation
will be reported. This does not apply to cases where a variable, call,
or complex expression is used in the index — detection is roughly
limited to static definitions, which matches Python's warnings.

```
❯ ./target/debug/ruff example.py --select RUF015 --show-source --no-cache
example.py:1:17: RUF015 Indexed access to type `list` uses type `str` instead of an integer or slice.
  |
1 | var = [1, 2, 3]["x"]
  |                 ^^^ RUF015
  |
```

Closes #5082
xref
python/cpython@ffff144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ruff fails to detect nonsensical list index
3 participants