Skip to content

Conversation

robsdedude
Copy link
Contributor

@robsdedude robsdedude commented Jun 8, 2025

Summary

As suggested here #18508 (comment), this PR makes UP045/UP007 not offer a fix for Optional[None]. Because

  1. rewriting it to None | None is not helpful or desired
  2. the user's intention is not clear

Related Issue

#18508

@robsdedude robsdedude marked this pull request as draft June 8, 2025 08:05
@robsdedude robsdedude changed the title [pyupgrade] Ignore Optional[None] in non-pep604-annotation-optional (UP045) and non-pep604-annotation-union (UP007) [pyupgrade] Don't offer fix for Optional[None] in non-pep604-annotation-optional (UP045) or non-pep604-annotation-union (UP007) Jun 8, 2025
@robsdedude robsdedude force-pushed the fix/18508-up045-ignore-optional-none branch from 954e2a0 to 3756987 Compare June 8, 2025 08:10
Copy link
Contributor

github-actions bot commented Jun 8, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@robsdedude robsdedude marked this pull request as ready for review June 8, 2025 08:33
@MichaReiser MichaReiser added the fixes Related to suggested fixes for violations label Jun 11, 2025
@MichaReiser
Copy link
Member

Thank you

@MichaReiser MichaReiser merged commit 0724bee into astral-sh:main Jun 11, 2025
34 checks passed
@robsdedude robsdedude deleted the fix/18508-up045-ignore-optional-none branch June 11, 2025 06:30
dcreager added a commit that referenced this pull request Jun 12, 2025
* main:
  [ty] Add some "inside string" tests for `object.<CURSOR>` completions
  [ty] Pull types on synthesized Python files created by mdtest (#18539)
  Update Rust crate anstyle to v1.0.11 (#18583)
  [`pyupgrade`] Fix `super(__class__, self)` detection in UP008 (super-call-with-parameters) (#18478)
  [ty] Generate the top and bottom materialization of a type (#18594)
  `SourceOrderVisitor` should visit the `Identifier` part of the `PatternKeyword` node (#18635)
  Update salsa (#18636)
  [ty] Update mypy_primer doc (#18638)
  [ty] Improve support for `object.<CURSOR>` completions
  [ty] Add `CoveringNode::find_last`
  [ty] Refactor covering node representation
  [ty] Infer the Python version from `--python=<system installation>` on Unix (#18550)
  [`flake8-return`] Fix `RET504` autofix generating a syntax error (#18428)
  Fix incorrect salsa `return_ref` attribute (#18605)
  Move corpus tests to `ty_python_semantic` (#18609)
  [`pyupgrade`] Don't offer fix for `Optional[None]` in non-pep604-annotation-optional (`UP045)` or non-pep604-annotation-union (`UP007`) (#18545)
  [`pep8-naming`] Suppress fix for `N804` and `N805` if the recommend name is already used (#18472)
  [`ruff`] skip fix for `RUF059` if dummy name is already bound (unused-unpacked-variable) (#18509)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants