Skip to content

[pyupgrade] Stabilize non-pep604-annotation-optional (UP045) and preview behavior for non-pep604-annotation-union (UP007) #18505

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

Merged
merged 2 commits into from
Jun 9, 2025

Conversation

dylwil3
Copy link
Collaborator

@dylwil3 dylwil3 commented Jun 6, 2025

No description provided.

@dylwil3 dylwil3 added this to the v0.12 milestone Jun 6, 2025
@dylwil3 dylwil3 added the rule Implementing or modifying a lint rule label Jun 6, 2025
@dylwil3
Copy link
Collaborator Author

dylwil3 commented Jun 6, 2025

(@ntBre heads up this also does a rule stabilization - stepping on your toes here 😄 )

@dylwil3 dylwil3 force-pushed the dylan/stabilize-optional-union-up branch from f59ec11 to 5081d0a Compare June 6, 2025 17:19
Copy link
Contributor

github-actions bot commented Jun 6, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+3085 -857 violations, +0 -0 fixes in 6 projects; 49 projects unchanged)

apache/airflow (+4 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --no-preview --select ALL

+ airflow-core/src/airflow/utils/log/logging_mixin.py:75:30: UP045 Use `X | None` for type annotations
+ airflow-core/src/airflow/utils/log/logging_mixin.py:75:52: RUF100 [*] Unused `noqa` directive (unused: `UP007`)
+ airflow-core/src/airflow/utils/log/logging_mixin.py:77:19: UP045 Use `X | None` for type annotations
+ airflow-core/src/airflow/utils/log/logging_mixin.py:77:41: RUF100 [*] Unused `noqa` directive (unused: `UP007`)

apache/superset (+833 -833 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --no-preview --select ALL

- RELEASING/changelog.py:106:53: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/changelog.py:106:53: UP045 [*] Use `X | None` for type annotations
- RELEASING/changelog.py:72:23: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/changelog.py:72:23: UP045 [*] Use `X | None` for type annotations
- RELEASING/changelog.py:73:15: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/changelog.py:73:15: UP045 [*] Use `X | None` for type annotations
- RELEASING/changelog.py:78:45: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/changelog.py:78:45: UP045 [*] Use `X | None` for type annotations
- RELEASING/verify_release.py:59:42: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/verify_release.py:59:42: UP045 [*] Use `X | None` for type annotations
- RELEASING/verify_release.py:59:57: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/verify_release.py:59:57: UP045 [*] Use `X | None` for type annotations
- RELEASING/verify_release.py:91:33: UP007 [*] Use `X | Y` for type annotations
+ RELEASING/verify_release.py:91:33: UP045 [*] Use `X | None` for type annotations
- scripts/cancel_github_workflows.py:156:21: UP007 [*] Use `X | Y` for type annotations
+ scripts/cancel_github_workflows.py:156:21: UP045 [*] Use `X | None` for type annotations
- scripts/cancel_github_workflows.py:65:13: UP007 [*] Use `X | Y` for type annotations
+ scripts/cancel_github_workflows.py:65:13: UP045 [*] Use `X | None` for type annotations
- scripts/cancel_github_workflows.py:95:13: UP007 [*] Use `X | Y` for type annotations
+ scripts/cancel_github_workflows.py:95:13: UP045 [*] Use `X | None` for type annotations
- scripts/cancel_github_workflows.py:96:11: UP007 [*] Use `X | Y` for type annotations
... 823 additional changes omitted for rule UP007
... 1645 additional changes omitted for project

binary-husky/gpt_academic (+11 -11 violations, +0 -0 fixes)

- crazy_functions/doc_fns/read_fns/excel_reader.py:186:22: UP007 Use `X | Y` for type annotations
+ crazy_functions/doc_fns/read_fns/excel_reader.py:186:22: UP045 Use `X | None` for type annotations
- crazy_functions/doc_fns/read_fns/excel_reader.py:40:32: UP007 Use `X | Y` for type annotations
+ crazy_functions/doc_fns/read_fns/excel_reader.py:40:32: UP045 Use `X | None` for type annotations
- crazy_functions/doc_fns/read_fns/excel_reader.py:96:60: UP007 Use `X | Y` for type annotations
+ crazy_functions/doc_fns/read_fns/excel_reader.py:96:60: UP045 Use `X | None` for type annotations
- crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py:171:26: UP007 Use `X | Y` for type annotations
+ crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py:171:26: UP045 Use `X | None` for type annotations
- crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py:46:17: UP007 Use `X | Y` for type annotations
+ crazy_functions/doc_fns/read_fns/markitdown/markdown_reader.py:46:17: UP045 Use `X | None` for type annotations
... 12 additional changes omitted for project

ibis-project/ibis (+105 -0 violations, +0 -0 fixes)

+ ibis/backends/bigquery/__init__.py:890:48: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:171:46: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:203:50: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:275:41: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:310:47: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:359:47: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:379:17: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:380:18: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:418:17: UP045 Use `X | None` for type annotations
+ ibis/common/graph.py:419:18: UP045 Use `X | None` for type annotations
... 95 additional changes omitted for project

langchain-ai/langchain (+2119 -0 violations, +0 -0 fixes)

+ libs/core/langchain_core/caches.py:100:62: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/caches.py:152:36: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/caches.py:170:55: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/caches.py:204:62: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/caches.py:55:55: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:107:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:128:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:145:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:162:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:179:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:200:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:217:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:239:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:240:15: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:241:19: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:266:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:267:15: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:268:19: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:296:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:297:15: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:298:19: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:319:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:320:15: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:321:19: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:32:24: UP045 Use `X | None` for type annotations
+ libs/core/langchain_core/callbacks/base.py:342:24: UP045 Use `X | None` for type annotations
... 2093 additional changes omitted for project

latchbio/latch (+13 -13 violations, +0 -0 fixes)

- src/latch/registry/record.py:188:57: UP007 Use `X | Y` for type annotations
+ src/latch/registry/record.py:188:57: UP045 Use `X | None` for type annotations
- src/latch/registry/record.py:190:64: UP007 Use `X | Y` for type annotations
+ src/latch/registry/record.py:190:64: UP045 Use `X | None` for type annotations
- src/latch/registry/record.py:215:53: UP007 Use `X | Y` for type annotations
+ src/latch/registry/record.py:215:53: UP045 Use `X | None` for type annotations
- src/latch/registry/record.py:217:60: UP007 Use `X | Y` for type annotations
+ src/latch/registry/record.py:217:60: UP045 Use `X | None` for type annotations
- src/latch/registry/record.py:250:10: UP007 Use `X | Y` for type annotations
+ src/latch/registry/record.py:250:10: UP045 Use `X | None` for type annotations
... 16 additional changes omitted for project

Changes by rule (3 rules affected)

code total + violation - violation + fix - fix
UP045 3083 3083 0 0 0
UP007 857 0 857 0 0
RUF100 2 2 0 0 0

Linter (preview)

✅ ecosystem check detected no linter changes.

@dylwil3
Copy link
Collaborator Author

dylwil3 commented Jun 6, 2025

Despite the alarming number of changes in the ecosystem check, this is correct since some repos have UP007 ignored - see #15313 (comment)

@ntBre
Copy link
Contributor

ntBre commented Jun 6, 2025

Keep stepping! There are plenty of toes to go around in this release 😆

In this case, we may need to hold off in light of #18508

@AlexWaygood
Copy link
Member

AlexWaygood commented Jun 6, 2025

In this case, we may need to hold off in light of #18508

IMO: I don't think that issue should block stabilisation on its own. It's a valid bug report and we should fix it, but it's also an extreme edge case that would almost never come up in real code (the only situations I can think of are generated code, or a very confused user 😄)

@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
@dylwil3 dylwil3 force-pushed the dylan/stabilize-optional-union-up branch from 5081d0a to 441438e Compare June 9, 2025 21:21
@ntBre ntBre mentioned this pull request Jun 9, 2025
2 tasks
@dylwil3 dylwil3 merged commit cf0cfb1 into brent/release-0.12.0 Jun 9, 2025
34 checks passed
@dylwil3 dylwil3 deleted the dylan/stabilize-optional-union-up branch June 9, 2025 22:25
ntBre pushed a commit that referenced this pull request Jun 10, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
ntBre pushed a commit that referenced this pull request Jun 11, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
ntBre pushed a commit that referenced this pull request Jun 11, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
ntBre pushed a commit that referenced this pull request Jun 12, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
ntBre pushed a commit that referenced this pull request Jun 16, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
ntBre pushed a commit that referenced this pull request Jun 17, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
ntBre pushed a commit that referenced this pull request Jun 17, 2025
…d preview behavior for `non-pep604-annotation-union` (`UP007`) (#18505)
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.

3 participants