Skip to content

Typing errors after upgrading to 1.34 #4615

Closed
@remohammadi

Description

@remohammadi

Describe your environment

OS: Mac OS X
Python version: 3.13.3
SDK version: 1.34.0
API version: 1.34.0

What happened?

Just after updating opentelemetry-sdk to the version released a few hours ago, I am receiving '"opentelemetry.sdk.resources" has no attribute "Resource"' error when type checking my code, on the line that simply imports it:

from opentelemetry.sdk.resources import SERVICE_NAME, SERVICE_VERSION, Resource
mypy src --install-types --non-interactive
src/vinder/otel_utils.py:8: error: Module "opentelemetry.sdk.resources" has no attribute "SERVICE_NAME"  [attr-defined]
src/vinder/otel_utils.py:8: error: Module "opentelemetry.sdk.resources" has no attribute "SERVICE_VERSION"  [attr-defined]
src/vinder/otel_utils.py:8: error: Module "opentelemetry.sdk.resources" has no attribute "Resource"  [attr-defined]
Found 3 errors in 1 file (checked 94 source files)

Is this expected? Am I importing them from an internal module?

Steps to Reproduce

pip install --upgrade opentelemetry-sdk?

Expected Result

No typing errors for that line.

Actual Result

'Module "opentelemetry.sdk.resources" has no attribute X' errors

Additional context

No response

Would you like to implement a fix?

None

Activity

changed the title [-]Typing errors after upgraing to 1.34[/-] [+]Typing errors after upgrading to 1.34[/+] on Jun 4, 2025
xrmx

xrmx commented on Jun 5, 2025

@xrmx
Contributor

I think this is coming from the the deprecated implementation rework in c9ad4bc, if I remove # type: ignore[reportDeprecated] # ResourceAttributes is deprecated it works just fine

So I guess the quick fix would be to remove that line if pyright is fine with that

methane

methane commented on Jun 5, 2025

@methane
Contributor

or # pyright: ignore[reportDeprecated].

aabmass

aabmass commented on Jun 5, 2025

@aabmass
Member

This is a bit of a mess, sorry folks. I think this is the relevant part of mypy docs

Note that a # type: ignore comment at the top of a module (before any statements, including imports or docstrings) has the effect of ignoring the entire contents of the module. This behaviour can be surprising and result in “Module … has no attribute … [attr-defined]” errors.

Very surprising indeed. I tested and moving the ignore after the doc string fixes the mypy issue but then pyright silencing no longer works because those comments only work for line-level controls (see here). We need

# ResourceAttributes is deprecated
# pyright: reportDeprecated=warning
aabmass

aabmass commented on Jun 6, 2025

@aabmass
Member

We're planning a patch release for this early next week

added a commit that references this issue on Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @xrmx@remohammadi@methane@aabmass

      Issue actions

        Typing errors after upgrading to 1.34 · Issue #4615 · open-telemetry/opentelemetry-python