Skip to content

Remove typing aliases deprecated in python 3.9. Also replace usages of typing.Union/Optional with |#5277

Merged
xrmx merged 12 commits into
open-telemetry:mainfrom
DylanRussell:new11
Jun 17, 2026
Merged

Remove typing aliases deprecated in python 3.9. Also replace usages of typing.Union/Optional with |#5277
xrmx merged 12 commits into
open-telemetry:mainfrom
DylanRussell:new11

Conversation

@DylanRussell

@DylanRussell DylanRussell commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

Removing typing aliases deprecated in python 3.9 -- see https://docs.python.org/3/library/typing.html#deprecated-aliases -- replacing them with the now supported collections.abc equivalent

Replace all usages of typing.Union and typing.Optional with |.

Type of change

  • [ x] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Unit tests

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • [ x] No.

Checklist:

  • [ x] Followed the style guidelines of this project
  • [ x] Changelogs have been updated
  • [ x] Unit tests have been added
  • [ x] Documentation has been updated

@DylanRussell DylanRussell requested a review from a team as a code owner June 5, 2026 19:41
@DylanRussell DylanRussell changed the title Remove typing aliases deprecated in python 3.9 Remove typing aliases deprecated in python 3.9. Also replace usages of typing.Union with | Jun 5, 2026
Comment thread codegen/opentelemetry-codegen-json/src/opentelemetry/codegen/json/generator.py Outdated
DylanRussell and others added 2 commits June 8, 2026 14:36
…son/generator.py

Co-authored-by: Lukas Hering <40302054+herin049@users.noreply.github.com>
Comment thread opentelemetry-proto-json/src/opentelemetry/proto_json/logs/v1/logs.py Outdated

@emdneto emdneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure why ruff didn't catch this

@DylanRussell DylanRussell changed the title Remove typing aliases deprecated in python 3.9. Also replace usages of typing.Union with | Remove typing aliases deprecated in python 3.9. Also replace usages of typing.Union/Optional with | Jun 9, 2026
@DylanRussell DylanRussell moved this to Easy to review / merge / close in Python PR digest Jun 10, 2026
@DylanRussell DylanRussell moved this to Easy to review / merge / close in Python PR digest Jun 10, 2026
@Kludex

Kludex commented Jun 11, 2026

Copy link
Copy Markdown
Member

Ruff has the "UP" rule, fyi.

@DylanRussell

Copy link
Copy Markdown
Contributor Author

https://docs.astral.sh/ruff/rules/#pyupgrade-up doesn't seem to include these typing deprecations yet. Not sure why it didn't catch Union/Optional replaced by | as it appears to have a UP rule for that.. Anyway I think this should be good to merge now

@DylanRussell

Copy link
Copy Markdown
Contributor Author

I think the failing checks should be suppressed..

@github-project-automation github-project-automation Bot moved this from Easy to review / merge / close to Approved PRs in Python PR digest Jun 17, 2026
@xrmx xrmx moved this from Approved PRs to Ready for merge in Python PR digest Jun 17, 2026
@xrmx xrmx added Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary Skip Changelog PRs that do not require a CHANGELOG.md entry and removed Skip Changelog PRs that do not require a CHANGELOG.md entry labels Jun 17, 2026
@xrmx xrmx enabled auto-merge June 17, 2026 12:49
@xrmx xrmx disabled auto-merge June 17, 2026 13:09
@xrmx xrmx added this pull request to the merge queue Jun 17, 2026
Merged via the queue into open-telemetry:main with commit 7283c4c Jun 17, 2026
1034 of 1036 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for merge to Done in Python PR digest Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants