Skip to content

Re-enable the T and C linter prefix selectors - #3452

Merged
charliermarsh merged 1 commit into
mainfrom
charlie/t
Mar 13, 2023
Merged

Re-enable the T and C linter prefix selectors#3452
charliermarsh merged 1 commit into
mainfrom
charlie/t

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Mar 11, 2023

Copy link
Copy Markdown
Member

Summary

In one of the prior refactors around lint rule prefixes, we removed the T and C selectors.

To take T as an example, the issue is that we have two "linters" that both use the T prefix -- flake8-debugger, whose rules are (e.g.) T100, and flake8-print, whose rules are (e.g.) T201. In the refactored model, flake8-debugger was represented as having a prefix of T10, and a rule under that prefix with code 0, which combines to an overall selector of T100.

Under this scheme, if the user provides the T prefix, we don't know where to map that code. Prior to this PR, it was redirected to T10, so if a user provided --select T, that aliased to --select T10, which enabled rule T100, thus ignoring the flake8-print rules entirely. I believe this was unintentional.

The same problem exists with the C prefix, where we have both the McCabe complexity and flake8-comprehensions rules. The McCabe rules no longer run under --select C, because it was redirected to C40.

This PR special-cases those two prefixes, introducing custom selectors for T and C to re-enable the expected user behavior.

Closes #3052.

@charliermarsh charliermarsh added the bug Something isn't working label Mar 11, 2023
@github-actions

Copy link
Copy Markdown
Contributor

✅ ecosystem check detected no changes.

// The following are here because we don't yet have the many-to-one mapping enabled.
("SIM111", "SIM110"),
// The following are deprecated.
("C", "C4"),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No longer need to redirect these at all, since they have their own custom selectors.

@charliermarsh

Copy link
Copy Markdown
Member Author

There are likely further refactors we can do here, but I'd like to get this out in the next release as it's probably surprising to users that certain codes are no longer enforced despite no change in their selectors (e.g., select = ["C"] no longer runs the complexity checks).

@charliermarsh
charliermarsh merged commit 227679b into main Mar 13, 2023
@charliermarsh
charliermarsh deleted the charlie/t branch March 13, 2023 12:20
renovate Bot referenced this pull request in ixm-one/pytest-cmake-presets Mar 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://togithub.com/charliermarsh/ruff) | `^0.0.254` ->
`^0.0.255` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.255/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.255/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.255/compatibility-slim/0.0.254)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.255/confidence-slim/0.0.254)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

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

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

#### What's Changed

##### Rules

- \[`flake8-pie`] Fix PIE802 broken auto-fix with trailing comma by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3402](https://togithub.com/charliermarsh/ruff/pull/3402)
- \[`flake8-pie`] Implement autofix for PIE810 by
[@&#8203;kyoto7250](https://togithub.com/kyoto7250) in
[https://github.com/charliermarsh/ruff/pull/3411](https://togithub.com/charliermarsh/ruff/pull/3411)
- \[`flake8-bugbear`] Add `flake8-bugbear`'s B030 rule by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[https://github.com/charliermarsh/ruff/pull/3400](https://togithub.com/charliermarsh/ruff/pull/3400)
- \[`pycodestyle`] Add E231 by
[@&#8203;carlosmiei](https://togithub.com/carlosmiei) in
[https://github.com/charliermarsh/ruff/pull/3344](https://togithub.com/charliermarsh/ruff/pull/3344)
- \[`pyupgrade`] Flag deprecated (but renamed) imports in UP035 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3448](https://togithub.com/charliermarsh/ruff/pull/3448)
- \[`pyupgrade`] Remap ChainMap, Counter, and OrderedDict imports to
collections by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3392](https://togithub.com/charliermarsh/ruff/pull/3392)
- \[`pylint`] C1901: compare-to-empty-string by
[@&#8203;AreamanM](https://togithub.com/AreamanM) in
[https://github.com/charliermarsh/ruff/pull/3405](https://togithub.com/charliermarsh/ruff/pull/3405)
- \[`pylint`] Implement W1508 invalid-envvar-default by
[@&#8203;latonis](https://togithub.com/latonis) in
[https://github.com/charliermarsh/ruff/pull/3449](https://togithub.com/charliermarsh/ruff/pull/3449)
- \[`pylint`] Implement E1507 invalid-envvar-value by
[@&#8203;latonis](https://togithub.com/latonis) in
[https://github.com/charliermarsh/ruff/pull/3467](https://togithub.com/charliermarsh/ruff/pull/3467)

##### Settings

- Infer `target-version` from project metadata by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3470](https://togithub.com/charliermarsh/ruff/pull/3470)
- Implement configuration options `runtime-evaluated-decorators` and
`runtime-evaluated-base-classes` for `flake8-type-checking` by
[@&#8203;sasanjac](https://togithub.com/sasanjac) in
[https://github.com/charliermarsh/ruff/pull/3292](https://togithub.com/charliermarsh/ruff/pull/3292)
- Add Azure DevOps as a `--format` option. by
[@&#8203;StefanBRas](https://togithub.com/StefanBRas) in
[https://github.com/charliermarsh/ruff/pull/3335](https://togithub.com/charliermarsh/ruff/pull/3335)

##### Bug Fixes

- Re-enable the T and C linter prefix selectors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3452](https://togithub.com/charliermarsh/ruff/pull/3452)
- Treat unary operations on constants as constant-like by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3348](https://togithub.com/charliermarsh/ruff/pull/3348)
- Skip byte-order-mark at start of file by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3343](https://togithub.com/charliermarsh/ruff/pull/3343)
- Don't enforce typing-import rules in .pyi files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3362](https://togithub.com/charliermarsh/ruff/pull/3362)
- Include entire prefix when reporting rule selector errors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3375](https://togithub.com/charliermarsh/ruff/pull/3375)
- Handle multi-line fixes for byte-string prefixing by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3391](https://togithub.com/charliermarsh/ruff/pull/3391)
- Catch RET504 usages via decorators by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3395](https://togithub.com/charliermarsh/ruff/pull/3395)
- Ignore multiply-assigned variables in RET504 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3393](https://togithub.com/charliermarsh/ruff/pull/3393)
- \[FIX] PYI011: recognize `Bool` / `Float` / `Complex` numbers as
simple defaults by [@&#8203;XuehaiPan](https://togithub.com/XuehaiPan)
in
[https://github.com/charliermarsh/ruff/pull/3459](https://togithub.com/charliermarsh/ruff/pull/3459)
- Respect ignores for runtime-import-in-type-checking-block (TCH004) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3474](https://togithub.com/charliermarsh/ruff/pull/3474)
- Avoid panicking in invalid_escape_sequence by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3338](https://togithub.com/charliermarsh/ruff/pull/3338)
- fix: Emit a more useful error if an `extend` points at a non-existent
ruff.toml file. by [@&#8203;DanCardin](https://togithub.com/DanCardin)
in
[https://github.com/charliermarsh/ruff/pull/3417](https://togithub.com/charliermarsh/ruff/pull/3417)
- Respect `--show-fixes` with `--fix-only` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3426](https://togithub.com/charliermarsh/ruff/pull/3426)
- When "Args" and "Parameters" are present, prefer NumPy style by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3430](https://togithub.com/charliermarsh/ruff/pull/3430)
- Remove empty line after RUF100 auto-fix by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3414](https://togithub.com/charliermarsh/ruff/pull/3414)
- Avoid removing un-aliased exceptions in `OSError`-aliased handlers by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3451](https://togithub.com/charliermarsh/ruff/pull/3451)
- Use a hash to fingerprint GitLab CI output by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3456](https://togithub.com/charliermarsh/ruff/pull/3456)
- Avoid respecting noqa directives when RUF100 is enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3469](https://togithub.com/charliermarsh/ruff/pull/3469)
- Output GitLab paths relative to `CI_PROJECT_DIR` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3475](https://togithub.com/charliermarsh/ruff/pull/3475)
- Implement an iterator for universal newlines by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3454](https://togithub.com/charliermarsh/ruff/pull/3454)

#### New Contributors

- [@&#8203;sasanjac](https://togithub.com/sasanjac) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3292](https://togithub.com/charliermarsh/ruff/pull/3292)
- [@&#8203;aacunningham](https://togithub.com/aacunningham) made their
first contribution in
[https://github.com/charliermarsh/ruff/pull/3380](https://togithub.com/charliermarsh/ruff/pull/3380)
- [@&#8203;orf](https://togithub.com/orf) made their first contribution
in
[https://github.com/charliermarsh/ruff/pull/3389](https://togithub.com/charliermarsh/ruff/pull/3389)
- [@&#8203;DanCardin](https://togithub.com/DanCardin) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3417](https://togithub.com/charliermarsh/ruff/pull/3417)
- [@&#8203;AreamanM](https://togithub.com/AreamanM) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3405](https://togithub.com/charliermarsh/ruff/pull/3405)
- [@&#8203;kyoto7250](https://togithub.com/kyoto7250) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3411](https://togithub.com/charliermarsh/ruff/pull/3411)
- [@&#8203;latonis](https://togithub.com/latonis) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3449](https://togithub.com/charliermarsh/ruff/pull/3449)
- [@&#8203;XuehaiPan](https://togithub.com/XuehaiPan) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3459](https://togithub.com/charliermarsh/ruff/pull/3459)
- [@&#8203;CalumY](https://togithub.com/CalumY) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3461](https://togithub.com/charliermarsh/ruff/pull/3461)
- [@&#8203;YDX-2147483647](https://togithub.com/YDX-2147483647) made
their first contribution in
[https://github.com/charliermarsh/ruff/pull/3473](https://togithub.com/charliermarsh/ruff/pull/3473)

**Full Changelog**:
astral-sh/ruff@v0.0.254...v0.0.255

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

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 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://togithub.com/charliermarsh/ruff) | `==0.0.254` ->
`==0.0.256` |
[![age](https://badges.renovateapi.com/packages/pypi/ruff/0.0.256/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/pypi/ruff/0.0.256/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/pypi/ruff/0.0.256/compatibility-slim/0.0.254)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/pypi/ruff/0.0.256/confidence-slim/0.0.254)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

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

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

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

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

#### What's Changed

##### Bug Fixes

- PYI011: allow `math` constants in defaults by
[@&#8203;XuehaiPan](https://togithub.com/XuehaiPan) in
[https://github.com/charliermarsh/ruff/pull/3484](https://togithub.com/charliermarsh/ruff/pull/3484)
- Remove erroneous C4-to-C40 redirect by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3488](https://togithub.com/charliermarsh/ruff/pull/3488)
- fix lack of `not` in error message by
[@&#8203;Czaki](https://togithub.com/Czaki) in
[https://github.com/charliermarsh/ruff/pull/3497](https://togithub.com/charliermarsh/ruff/pull/3497)
- Ensure that redirect warnings appear exactly once per code by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3500](https://togithub.com/charliermarsh/ruff/pull/3500)
- Allow f-strings and concatenations in os.getenv by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3516](https://togithub.com/charliermarsh/ruff/pull/3516)
- Allow string percent formatting in os.getenv by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3518](https://togithub.com/charliermarsh/ruff/pull/3518)
- Refine complexity rules for try-except-else-finally by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3519](https://togithub.com/charliermarsh/ruff/pull/3519)
- Replicate inline comments when splitting single-line imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3521](https://togithub.com/charliermarsh/ruff/pull/3521)
- Avoid PEP 604 isinstance errors for starred tuples by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3527](https://togithub.com/charliermarsh/ruff/pull/3527)
- Avoid tracking as-imports separately with force-single-line by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3530](https://togithub.com/charliermarsh/ruff/pull/3530)
- Fix PYI011 and add auto-fix by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3492](https://togithub.com/charliermarsh/ruff/pull/3492)
- Avoid PEP 604 panic with empty tuple by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3526](https://togithub.com/charliermarsh/ruff/pull/3526)
- Add last remaining deprecated typing imports by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3529](https://togithub.com/charliermarsh/ruff/pull/3529)
- Avoid unused argument violations in .pyi files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3533](https://togithub.com/charliermarsh/ruff/pull/3533)

##### Other Changes

- Include individual path checks in --verbose logging by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3489](https://togithub.com/charliermarsh/ruff/pull/3489)
- Allow `# ruff:` prefix for isort action comments by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3493](https://togithub.com/charliermarsh/ruff/pull/3493)

**Full Changelog**:
astral-sh/ruff@v0.0.255...v0.0.256

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

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

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

#### What's Changed

##### Rules

- \[`flake8-pie`] Fix PIE802 broken auto-fix with trailing comma by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3402](https://togithub.com/charliermarsh/ruff/pull/3402)
- \[`flake8-pie`] Implement autofix for PIE810 by
[@&#8203;kyoto7250](https://togithub.com/kyoto7250) in
[https://github.com/charliermarsh/ruff/pull/3411](https://togithub.com/charliermarsh/ruff/pull/3411)
- \[`flake8-bugbear`] Add `flake8-bugbear`'s B030 rule by
[@&#8203;aacunningham](https://togithub.com/aacunningham) in
[https://github.com/charliermarsh/ruff/pull/3400](https://togithub.com/charliermarsh/ruff/pull/3400)
- \[`pycodestyle`] Add E231 by
[@&#8203;carlosmiei](https://togithub.com/carlosmiei) in
[https://github.com/charliermarsh/ruff/pull/3344](https://togithub.com/charliermarsh/ruff/pull/3344)
- \[`pyupgrade`] Flag deprecated (but renamed) imports in UP035 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3448](https://togithub.com/charliermarsh/ruff/pull/3448)
- \[`pyupgrade`] Remap ChainMap, Counter, and OrderedDict imports to
collections by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3392](https://togithub.com/charliermarsh/ruff/pull/3392)
- \[`pylint`] C1901: compare-to-empty-string by
[@&#8203;AreamanM](https://togithub.com/AreamanM) in
[https://github.com/charliermarsh/ruff/pull/3405](https://togithub.com/charliermarsh/ruff/pull/3405)
- \[`pylint`] Implement W1508 invalid-envvar-default by
[@&#8203;latonis](https://togithub.com/latonis) in
[https://github.com/charliermarsh/ruff/pull/3449](https://togithub.com/charliermarsh/ruff/pull/3449)
- \[`pylint`] Implement E1507 invalid-envvar-value by
[@&#8203;latonis](https://togithub.com/latonis) in
[https://github.com/charliermarsh/ruff/pull/3467](https://togithub.com/charliermarsh/ruff/pull/3467)

##### Settings

- Infer `target-version` from project metadata by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3470](https://togithub.com/charliermarsh/ruff/pull/3470)
- Implement configuration options `runtime-evaluated-decorators` and
`runtime-evaluated-base-classes` for `flake8-type-checking` by
[@&#8203;sasanjac](https://togithub.com/sasanjac) in
[https://github.com/charliermarsh/ruff/pull/3292](https://togithub.com/charliermarsh/ruff/pull/3292)
- Add Azure DevOps as a `--format` option. by
[@&#8203;StefanBRas](https://togithub.com/StefanBRas) in
[https://github.com/charliermarsh/ruff/pull/3335](https://togithub.com/charliermarsh/ruff/pull/3335)

##### Bug Fixes

- Re-enable the T and C linter prefix selectors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3452](https://togithub.com/charliermarsh/ruff/pull/3452)
- Treat unary operations on constants as constant-like by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3348](https://togithub.com/charliermarsh/ruff/pull/3348)
- Skip byte-order-mark at start of file by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3343](https://togithub.com/charliermarsh/ruff/pull/3343)
- Don't enforce typing-import rules in .pyi files by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3362](https://togithub.com/charliermarsh/ruff/pull/3362)
- Include entire prefix when reporting rule selector errors by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3375](https://togithub.com/charliermarsh/ruff/pull/3375)
- Handle multi-line fixes for byte-string prefixing by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3391](https://togithub.com/charliermarsh/ruff/pull/3391)
- Catch RET504 usages via decorators by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3395](https://togithub.com/charliermarsh/ruff/pull/3395)
- Ignore multiply-assigned variables in RET504 by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3393](https://togithub.com/charliermarsh/ruff/pull/3393)
- \[FIX] PYI011: recognize `Bool` / `Float` / `Complex` numbers as
simple defaults by [@&#8203;XuehaiPan](https://togithub.com/XuehaiPan)
in
[https://github.com/charliermarsh/ruff/pull/3459](https://togithub.com/charliermarsh/ruff/pull/3459)
- Respect ignores for runtime-import-in-type-checking-block (TCH004) by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3474](https://togithub.com/charliermarsh/ruff/pull/3474)
- Avoid panicking in invalid_escape_sequence by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3338](https://togithub.com/charliermarsh/ruff/pull/3338)
- fix: Emit a more useful error if an `extend` points at a non-existent
ruff.toml file. by [@&#8203;DanCardin](https://togithub.com/DanCardin)
in
[https://github.com/charliermarsh/ruff/pull/3417](https://togithub.com/charliermarsh/ruff/pull/3417)
- Respect `--show-fixes` with `--fix-only` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3426](https://togithub.com/charliermarsh/ruff/pull/3426)
- When "Args" and "Parameters" are present, prefer NumPy style by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3430](https://togithub.com/charliermarsh/ruff/pull/3430)
- Remove empty line after RUF100 auto-fix by
[@&#8203;JonathanPlasse](https://togithub.com/JonathanPlasse) in
[https://github.com/charliermarsh/ruff/pull/3414](https://togithub.com/charliermarsh/ruff/pull/3414)
- Avoid removing un-aliased exceptions in `OSError`-aliased handlers by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3451](https://togithub.com/charliermarsh/ruff/pull/3451)
- Use a hash to fingerprint GitLab CI output by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3456](https://togithub.com/charliermarsh/ruff/pull/3456)
- Avoid respecting noqa directives when RUF100 is enabled by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3469](https://togithub.com/charliermarsh/ruff/pull/3469)
- Output GitLab paths relative to `CI_PROJECT_DIR` by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3475](https://togithub.com/charliermarsh/ruff/pull/3475)
- Implement an iterator for universal newlines by
[@&#8203;charliermarsh](https://togithub.com/charliermarsh) in
[https://github.com/charliermarsh/ruff/pull/3454](https://togithub.com/charliermarsh/ruff/pull/3454)

#### New Contributors

- [@&#8203;sasanjac](https://togithub.com/sasanjac) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3292](https://togithub.com/charliermarsh/ruff/pull/3292)
- [@&#8203;aacunningham](https://togithub.com/aacunningham) made their
first contribution in
[https://github.com/charliermarsh/ruff/pull/3380](https://togithub.com/charliermarsh/ruff/pull/3380)
- [@&#8203;orf](https://togithub.com/orf) made their first contribution
in
[https://github.com/charliermarsh/ruff/pull/3389](https://togithub.com/charliermarsh/ruff/pull/3389)
- [@&#8203;DanCardin](https://togithub.com/DanCardin) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3417](https://togithub.com/charliermarsh/ruff/pull/3417)
- [@&#8203;AreamanM](https://togithub.com/AreamanM) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3405](https://togithub.com/charliermarsh/ruff/pull/3405)
- [@&#8203;kyoto7250](https://togithub.com/kyoto7250) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3411](https://togithub.com/charliermarsh/ruff/pull/3411)
- [@&#8203;latonis](https://togithub.com/latonis) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3449](https://togithub.com/charliermarsh/ruff/pull/3449)
- [@&#8203;XuehaiPan](https://togithub.com/XuehaiPan) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3459](https://togithub.com/charliermarsh/ruff/pull/3459)
- [@&#8203;CalumY](https://togithub.com/CalumY) made their first
contribution in
[https://github.com/charliermarsh/ruff/pull/3461](https://togithub.com/charliermarsh/ruff/pull/3461)
- [@&#8203;YDX-2147483647](https://togithub.com/YDX-2147483647) made
their first contribution in
[https://github.com/charliermarsh/ruff/pull/3473](https://togithub.com/charliermarsh/ruff/pull/3473)

**Full Changelog**:
astral-sh/ruff@v0.0.254...v0.0.255

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

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
mtshiba added a commit that referenced this pull request Jun 6, 2026
Extend the structureless-cycle → `Never` resolution to `place_by_id` so that
value/place cycles with no base case — e.g. a cyclic import `A = A`, or a
loop-carried local defined only in terms of itself — resolve to `Never`
instead of exposing the bare `Divergent` marker, matching the attribute-cycle
behavior. Factored the resolution into `Type::resolve_structureless_cycle_to_never`
and reused it from `wrap_structural_recursive`.

Type-alias value cycles are deliberately excluded (they go through
`Type::cycle_normalized` directly, not the place path): resolving a
self-referential alias to `Never` would reintroduce the generic
recursive-alias type-argument proliferation (#3452).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mtshiba added a commit that referenced this pull request Jun 24, 2026
…generic recursive-alias overflow)

`PEP695TypeAliasType::value_type` applied the alias's own specialization
(`apply_function_specialization`) to the raw body *before* folding self-references
to `Divergent`. For a generic recursive alias whose self-reference uses a deeper
specialization than the alias's own parameters — e.g.

    type A[T] = Callable[[A[T]], A[T | A[T]]]
    type A[**P] = Callable[[], A[Concatenate[int, P]]]

the specialization walk descended into the nested `A[…]` reference, recomputed
`value_type` for an ever-deeper specialization, and never reached a fixed point —
a stack overflow / non-convergence (ty issue #3452). The same path also overflowed
on calling a parser-recovered recursive alias (`type A = | A` then `x()`,
ty issue #3196).

Fix: fold self-references to `Divergent(binder_id)` on the *raw* body first (the
fold already matches by definition, so any specialization of the alias folds), then
apply the alias's own specialization to the now-finite, self-reference-free body.
The recursive argument is conservatively simplified to the alias's own parameters at
the recursion point (`A[int | A[int]]` shown as `A[int]`), which is sound and stops
the proliferation. When the type argument does not grow through the recursion
(`type F[T] = list[F[T]]`), distinct specializations stay distinct (`F[int]` vs
`F[str]`).

Regression tests added for #3196 (call path) and #3452 (generic/ParamSpec recursive
callable aliases) in pep695_type_aliases.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mtshiba added a commit that referenced this pull request Jun 24, 2026
Extend the structureless-cycle → `Never` resolution to `place_by_id` so that
value/place cycles with no base case — e.g. a cyclic import `A = A`, or a
loop-carried local defined only in terms of itself — resolve to `Never`
instead of exposing the bare `Divergent` marker, matching the attribute-cycle
behavior. Factored the resolution into `Type::resolve_structureless_cycle_to_never`
and reused it from `wrap_structural_recursive`.

Type-alias value cycles are deliberately excluded (they go through
`Type::cycle_normalized` directly, not the place path): resolving a
self-referential alias to `Never` would reintroduce the generic
recursive-alias type-argument proliferation (#3452).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mtshiba added a commit that referenced this pull request Jun 24, 2026
…generic recursive-alias overflow)

`PEP695TypeAliasType::value_type` applied the alias's own specialization
(`apply_function_specialization`) to the raw body *before* folding self-references
to `Divergent`. For a generic recursive alias whose self-reference uses a deeper
specialization than the alias's own parameters — e.g.

    type A[T] = Callable[[A[T]], A[T | A[T]]]
    type A[**P] = Callable[[], A[Concatenate[int, P]]]

the specialization walk descended into the nested `A[…]` reference, recomputed
`value_type` for an ever-deeper specialization, and never reached a fixed point —
a stack overflow / non-convergence (ty issue #3452). The same path also overflowed
on calling a parser-recovered recursive alias (`type A = | A` then `x()`,
ty issue #3196).

Fix: fold self-references to `Divergent(binder_id)` on the *raw* body first (the
fold already matches by definition, so any specialization of the alias folds), then
apply the alias's own specialization to the now-finite, self-reference-free body.
The recursive argument is conservatively simplified to the alias's own parameters at
the recursion point (`A[int | A[int]]` shown as `A[int]`), which is sound and stops
the proliferation. When the type argument does not grow through the recursion
(`type F[T] = list[F[T]]`), distinct specializations stay distinct (`F[int]` vs
`F[str]`).

Regression tests added for #3196 (call path) and #3452 (generic/ParamSpec recursive
callable aliases) in pep695_type_aliases.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mtshiba added a commit that referenced this pull request Jun 24, 2026
Extend the structureless-cycle → `Never` resolution to `place_by_id` so that
value/place cycles with no base case — e.g. a cyclic import `A = A`, or a
loop-carried local defined only in terms of itself — resolve to `Never`
instead of exposing the bare `Divergent` marker, matching the attribute-cycle
behavior. Factored the resolution into `Type::resolve_structureless_cycle_to_never`
and reused it from `wrap_structural_recursive`.

Type-alias value cycles are deliberately excluded (they go through
`Type::cycle_normalized` directly, not the place path): resolving a
self-referential alias to `Never` would reintroduce the generic
recursive-alias type-argument proliferation (#3452).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mtshiba added a commit that referenced this pull request Jul 19, 2026
## Summary

Fixes ~~astral-sh/ty#3452~~
I intended to fix it, but the fixes were separated into #26881, #26882
and #26898. This PR provides a foundation for fixes, but there are
observable improvements on this PR alone. For example:

```py
from ty_extensions import static_assert
from ty_extensions._internal import is_subtype_of

type Left[T] = tuple[Left[list[T]]]
type Right[T] = tuple[Right[list[T]]]

# TODO: Left[int] should be equivalent to (subtype of) Right[int]
static_assert(not is_subtype_of(Left[int], Right[int]))
```

This will result in stack overflow in the current main.

A recursive type like `type StableRecursiveList[T] = T |
list[StableRecursiveList[T]]` can be checked without any problem even in
the current main. This is because the specialization that appears in the
recursive type on the right side is the same as the left side, so the
recursion guard using simple type equality works.

The problem here is that among recursive aliases, the specialization on
the right-hand side grows with each expansion. Current recursion guards
cannot notice such type alias reentrancy.

Therefore, when considering generic recursive type aliases, two levels
of protection must be applied, distinguishing between equivalence based
on type definition identity and full type equivalence, including
specialization. Applying a recursive guard that only considers the
latter will fail to detect cases of growing specialization (this is
exactly the problem exposed by MRE). On the other hand, if we guard by
considering only the former, specialization will not be considered, so
we will treat `GrowingList[int]` and `GrowingList[str]` as the same
thing.

With this PR, the `CycleDetector` will now return a `Cycle` state in
addition to `Ready` and `Pending` as a result of a visit. If the type
aliases, including specializations, are equivalent to types already seen
during the visit, the detector will still return the fallback value as
`Ready`. If the type aliases are the same but the specializations are
different, return `Cycle` and ask the upstream relation checker to
decide. In the case of `TypeRelationChecker`, when this is received, it
executes `recursive_type_pair_fallback` to complete the determination.

---

So, what should `recursive_type_pair_fallback` do? If we call
`check_type_pair` during this process, we will enter recursion again, so
we need to make it a finite process. As I thought about it, I realized
that this problem was undecidable. There is no general subtyping
algorithm for growing recursive type aliases. This is because they will
have expressive power equal to or greater than that of context-free
grammars [^1]. In other words, determining the subtype of two such
recursive aliases is the same problem as determining the equivalence and
inclusion of two CFGs that are known to be undecidable.

```py
from typing import Literal, final
from ty_extensions import static_assert
from ty_extensions._internal import is_subtype_of

@Final
class End:
    pass

type AAnd[Rest] = tuple[Literal["a"], Rest]
type BAnd[Rest] = tuple[Literal["b"], Rest]

# S -> ε | aSb
# {a^n b^n | n >= 0}
type S[Rest] = Rest | AAnd[S[BAnd[Rest]]]
# T -> ε | aTb | aaTbb
# {a^n b^n | n >= 0}
type T[Rest] = Rest | AAnd[T[BAnd[Rest]]] | AAnd[AAnd[T[BAnd[BAnd[Rest]]]]]

# S and T produce exactly the same language, but the type checker cannot tell that.
static_assert(not is_subtype_of(S[End], T[End]))
```

Therefore, we have to give up on this kind of recursive alias typing at
some point (FYI, mypy makes growing recursive aliases like this illegal
in the first place; pyright allows them, but seems to just have a
recursion depth limit).
In this PR, it simply returns a conservative solution immediately when a
growing pattern of recursive type alias is detected. In reality, we can
extend the support a little more, but we'll leave that as future work
and focus on fixes first.

---

#26881 strengthens the recursion guard in `TypeTransformer` under this
PR change. This directly fixes #3452.
#26882 strengthens the recursion guard in `UnionBuilder` under this PR
change. This will properly stop the expansion of recursive union aliases
that would result in stack overflow in the current main.
#26898 adds `RecursionGuard` that wraps `TypeCollector`.

[^1]: To be more specific, the type argument of type alias can be
considered as the stack memory of a pushdown automaton. If the generic
type alias itself appears on the right side with a different
specialization than the left side, it corresponds to being able to push
additional information onto the stack along with the state transition.
If it has only trivial specializations like the left side, it cannot be
used as a stack, and its abilities are equivalent to a finite automaton.

## Test Plan

new mdtest cases

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C901 (max-complexity) not reported since 0.0.247

3 participants