Closed
Description
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
[-]Typing errors after upgraing to 1.34[/-][+]Typing errors after upgrading to 1.34[/+]xrmx commentedon Jun 5, 2025
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 fineSo I guess the quick fix would be to remove that line if pyright is fine with that
methane commentedon Jun 5, 2025
or
# pyright: ignore[reportDeprecated]
.fix: ignore mypy error from latest OpenTelemetrySDK update
aabmass commentedon Jun 5, 2025
This is a bit of a mess, sorry folks. I think this is the relevant part of mypy docs
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
type: ignore
that causes mypy to ignore the whole file #4618fix: ignore mypy error from latest OpenTelemetrySDK update (#180)
aabmass commentedon Jun 6, 2025
We're planning a patch release for this early next week
Remove `type: ignore` annotation
type: ignore
annotation appsignal/appsignal-python#243fix: ignore mypy error from latest OpenTelemetrySDK update (strands-a…
fix: ignore mypy error from latest OpenTelemetrySDK update (strands-a…