镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Declare AnyValue and AttributeValue as explicit type aliases - #5703

Merged
xrmx merged 3 commits into
open-telemetry:mainfrom
jimbobbennett:fix-anyvalue-type-alias
Sep 29, 2026
Merged

xrmx merged 3 commits into
open-telemetry:mainfrom
jimbobbennett:fix-anyvalue-type-alias

Conversation

@jimbobbennett

@jimbobbennett jimbobbennett commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5701

Description

AnyValue = AttributeValue = ... is a chained assignment, which type checkers don't recognize as a type alias: mypy rejects both names and pyright rejects AnyValue, so annotations using them fail with valid-type / reportInvalidTypeForm.

Fixes #5701

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

Verified with mypy and pyright. This was causing downstream issues in OpenInference and this change fixes those.

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

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

`AnyValue = AttributeValue = ...` is a chained assignment, which type
checkers don't recognize as a type alias: mypy rejects both names and
pyright rejects `AnyValue`, so annotations using them fail with
`valid-type` / `reportInvalidTypeForm`.

Fixes open-telemetry#5701

Assisted-by: Claude Opus 5.5
@jimbobbennett
jimbobbennett requested a review from a team as a code owner September 28, 2026 16:59
Assisted-by: Claude Opus 5.5
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-09-29 07:38 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved review issues remain.

Review effort: Lite
Findings: None

What changed in this PR

Fixes static type-checker recognition of AnyValue and AttributeValue by declaring them as explicit type aliases.

Changes:

  • Adds TypeAlias declarations for both public aliases.
  • Adds a changelog entry.
File Description
opentelemetry-api/​src/​opentelemetry/​util/​types.py Defines explicit type aliases.
.changelog/​5703.fixed Documents the typing fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@herin049 herin049 added the Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary label Sep 28, 2026
@jimbobbennett

Copy link
Copy Markdown
Contributor Author

Thanks for the label @herin049 - can you also re-run the failing checks?

@xrmx xrmx closed this Sep 29, 2026
@xrmx xrmx reopened this Sep 29, 2026
@github-project-automation github-project-automation Bot moved this from Approved PRs to Done in Python PR digest Sep 29, 2026
@xrmx
xrmx added this pull request to the merge queue Sep 29, 2026
Merged via the queue into open-telemetry:main with commit a514e9e Sep 29, 2026
1723 of 1727 checks passed
emdneto pushed a commit that referenced this pull request Oct 6, 2026
…5750)

* Declare AnyValue and AttributeValue as explicit type aliases

`AnyValue = AttributeValue = ...` is a chained assignment, which type
checkers don't recognize as a type alias: mypy rejects both names and
pyright rejects `AnyValue`, so annotations using them fail with
`valid-type` / `reportInvalidTypeForm`.

Fixes #5701

Assisted-by: Claude Opus 5.5

* Add changelog fragment

Assisted-by: Claude Opus 5.5

Co-authored-by: Jim Bennett <jimbobbennett@mac.com>
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.

AnyValue is not valid as a type

4 participants