Skip to content

[pyupgrade] Stabilize non-pep695-generic-class (UP046)#18519

Merged
ntBre merged 2 commits into
brent/release-0.12.0from
brent/stabilize-up046
Jun 12, 2025
Merged

[pyupgrade] Stabilize non-pep695-generic-class (UP046)#18519
ntBre merged 2 commits into
brent/release-0.12.0from
brent/stabilize-up046

Conversation

@ntBre
Copy link
Copy Markdown
Contributor

@ntBre ntBre commented Jun 6, 2025

Summary

  • Stabilizes UP046 (non-pep695-generic-class) rule by changing it from Preview to Stable

Test plan

  • ✅ Rule is already tested in main test function, no migration needed
  • make check passes
  • make test passes

Rule Documentation

@ntBre ntBre added the rule Implementing or modifying a lint rule label Jun 6, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre

This comment was marked as resolved.

@ntBre ntBre force-pushed the brent/release-0.12.0 branch 3 times, most recently from 9252447 to 829acf4 Compare June 9, 2025 00:22
@ntBre ntBre force-pushed the brent/stabilize-up046 branch from 2df4d98 to 8f6a501 Compare June 9, 2025 14:00
@ntBre

This comment was marked as resolved.

ntBre added a commit that referenced this pull request Jun 9, 2025
Summary
--

The tests were already in the right place, I just updated the documentation
slightly to reflect the discussion
[here](#18519 (comment)) and
on Discord.

Documentation: https://docs.astral.sh/ruff/rules/generic-not-last-base-class

Tests: https://github.com/astral-sh/ruff/blob/brent/release-0.12.0/crates/ruff_linter/src/rules/flake8_pyi/mod.rs#L51-L52

Test Plan
--

Existing tests
@ntBre ntBre force-pushed the brent/stabilize-up046 branch from 8f6a501 to 586b61d Compare June 10, 2025 14:41
@ntBre ntBre requested a review from dylwil3 June 10, 2025 16:28
@ntBre ntBre changed the title Stabilize UP046 (non-pep695-generic-class) Stabilize non-pep695-generic-class (UP046) Jun 10, 2025
@ntBre ntBre force-pushed the brent/release-0.12.0 branch from aaf6c9b to 96913d1 Compare June 10, 2025 20:44
@ntBre ntBre requested a review from AlexWaygood as a code owner June 10, 2025 20:44
@AlexWaygood AlexWaygood removed their request for review June 10, 2025 20:50
@ntBre ntBre force-pushed the brent/release-0.12.0 branch 2 times, most recently from 3ad0f1f to ff6fb14 Compare June 11, 2025 11:09
@ntBre ntBre force-pushed the brent/stabilize-up046 branch from 586b61d to 4e58b8d Compare June 11, 2025 11:17
@ntBre ntBre added this to the v0.12 milestone Jun 11, 2025
@ntBre ntBre mentioned this pull request Jun 11, 2025
2 tasks
Copy link
Copy Markdown
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Looks good to me. @AlexWaygood do you know if mypy and pyright support this by now or how limited the support still is?

That's my only hesitation for stabilizing this rule.

@AlexWaygood
Copy link
Copy Markdown
Member

I'm sure they both still have a couple of bugs in edge cases, but my understanding is that they both support PEP 695 pretty well at this point!

@ntBre
Copy link
Copy Markdown
Contributor Author

ntBre commented Jun 12, 2025

Nice, thank you both! Is the support good enough that I should remove these statements from the docs:

Not all type checkers fully support PEP 695 yet, so even valid fixes suggested by this rule may cause type checking to fail.

Or is that still fair to say?

@AlexWaygood
Copy link
Copy Markdown
Member

Hmm, python/mypy#18507 is still unfixed (which we uncovered as a result of the PR initially adding this rule!) Maybe we should link to that directly from the docs?

I guess that does feel like something that users could plausibly run into: even if it's not code you'd usually write manually, it's code that could plausibly be generated by this autofix. I don't know if we should hold back from stabilisation just because of the mypy bug, though: that decision doesn't make much sense from the perspective of pyright users.

Whatever the case: maybe we should link to that issue directly from the docs

@ntBre
Copy link
Copy Markdown
Contributor Author

ntBre commented Jun 12, 2025

Wow I forgot about that! I confirmed that it's still a problem on mypy 1.16. I'll update the docs here and in #18524.

@ntBre
Copy link
Copy Markdown
Contributor Author

ntBre commented Jun 12, 2025

I'll go ahead and merge these, happy to drop the commits if we decide they should stay in preview.

@ntBre ntBre changed the title Stabilize non-pep695-generic-class (UP046) [pyupgrade] Stabilize non-pep695-generic-class (UP046) Jun 12, 2025
@ntBre ntBre merged commit 630de4d into brent/release-0.12.0 Jun 12, 2025
34 checks passed
@ntBre ntBre deleted the brent/stabilize-up046 branch June 12, 2025 14:27
ntBre added a commit that referenced this pull request Jun 12, 2025
## Summary
- Stabilizes UP046 (non-pep695-generic-class) rule by changing it from
Preview to Stable

## Test plan
- ✅ Rule is already tested in main test function, no migration needed
- ✅ `make check` passes
- ✅ `make test` passes

## Rule Documentation
- [Test
file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/pyupgrade/mod.rs#L109-L110)
- [Rule
documentation](https://docs.astral.sh/ruff/rules/non-pep695-generic-class/)
ntBre added a commit that referenced this pull request Jun 16, 2025
## Summary
- Stabilizes UP046 (non-pep695-generic-class) rule by changing it from
Preview to Stable

## Test plan
- ✅ Rule is already tested in main test function, no migration needed
- ✅ `make check` passes
- ✅ `make test` passes

## Rule Documentation
- [Test
file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/pyupgrade/mod.rs#L109-L110)
- [Rule
documentation](https://docs.astral.sh/ruff/rules/non-pep695-generic-class/)
ntBre added a commit that referenced this pull request Jun 17, 2025
## Summary
- Stabilizes UP046 (non-pep695-generic-class) rule by changing it from
Preview to Stable

## Test plan
- ✅ Rule is already tested in main test function, no migration needed
- ✅ `make check` passes
- ✅ `make test` passes

## Rule Documentation
- [Test
file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/pyupgrade/mod.rs#L109-L110)
- [Rule
documentation](https://docs.astral.sh/ruff/rules/non-pep695-generic-class/)
ntBre added a commit that referenced this pull request Jun 17, 2025
## Summary
- Stabilizes UP046 (non-pep695-generic-class) rule by changing it from
Preview to Stable

## Test plan
- ✅ Rule is already tested in main test function, no migration needed
- ✅ `make check` passes
- ✅ `make test` passes

## Rule Documentation
- [Test
file](https://github.com/astral-sh/ruff/blob/main/crates/ruff_linter/src/rules/pyupgrade/mod.rs#L109-L110)
- [Rule
documentation](https://docs.astral.sh/ruff/rules/non-pep695-generic-class/)
carljm added a commit to MatthewMckee4/ruff that referenced this pull request Jun 17, 2025
…ence

* main: (71 commits)
  Bump 0.12.0 (astral-sh#18724)
  Revert "[ty] Offer "Did you mean...?" suggestions for unresolved `from` imports and unresolved attributes (astral-sh#18705)" (astral-sh#18721)
  [`flake8-return`] Stabilize only add `return None` at the end when fixing `implicit-return` (`RET503`) (astral-sh#18516)
  [`pyupgrade`] Stabilize `non-pep695-generic-function` (`UP047`) (astral-sh#18524)
  [`pyupgrade`] Stabilize `non-pep695-generic-class` (`UP046`) (astral-sh#18519)
  [`pandas-vet`] Deprecate `pandas-df-variable-name` (`PD901`) (astral-sh#18618)
  [`flake8-bandit`] Remove `suspicious-xmle-tree-usage` (`S320`) (astral-sh#18617)
  Stabilize `dataclass-enum` (`RUF049`) (astral-sh#18570)
  Stabilize `unnecessary-dict-index-lookup` (`PLR1733`) (astral-sh#18571)
  Remove rust-toolchain.toml from sdist (astral-sh#17925)
  Stabilize `starmap-zip` (`RUF058`) (astral-sh#18525)
  [`flake8-logging`] Stabilize `exc-info-outside-except-handler` (`LOG014`) (astral-sh#18517)
  [`pyupgrade`] Stabilize `non-pep604-annotation-optional` (`UP045`) and preview behavior for `non-pep604-annotation-union` (`UP007`) (astral-sh#18505)
  Stabilize `pytest-warns-too-broad` (`PT030`) (astral-sh#18568)
  Stabilize `for-loop-writes` (`FURB122`) (astral-sh#18565)
  Stabilize `pytest-warns-with-multiple-statements` (`PT031`) (astral-sh#18569)
  Stabilize `pytest-parameter-with-default-argument` (`PT028`) (astral-sh#18566)
  Stabilize `nan-comparison` (`PLW0177`) (astral-sh#18559)
  Stabilize `check-and-remove-from-set` (`FURB132`) (astral-sh#18560)
  Stabilize `unnecessary-round` (`RUF057`) (astral-sh#18563)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants