Fix span context manager typing by using ParamSpec from typing_extensions#4389
Merged
xrmx merged 1 commit intoopen-telemetry:mainfrom Jan 17, 2025
Merged
Fix span context manager typing by using ParamSpec from typing_extensions#4389xrmx merged 1 commit intoopen-telemetry:mainfrom
xrmx merged 1 commit intoopen-telemetry:mainfrom
Conversation
aabmass
commented
Jan 16, 2025
188fff3 to
f8df905
Compare
Merged
11 tasks
emdneto
reviewed
Jan 17, 2025
Member
There was a problem hiding this comment.
There is an issue I think is related and this PR also fix it: #3836
[tool.pyright]
pythonVersion = "3.8"
from opentelemetry import trace
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span(name="foo"):
print("Hello world!")
With this pyright config and running the example against main, results in this error ❌ :
(main) $ pyright example.py
/workspaces/opentelemetry-python/example.py
/workspaces/opentelemetry-python/example.py:5:35 - error: No parameter named "name" (reportCallIssue)
1 error, 0 warnings, 0 informations
Running against this branch results in ✅ :
(agnostic-type-fix) $ pyright example.py
0 errors, 0 warnings, 0 informations
Member
Author
Yup looks like the same issue 👍 |
xrmx
approved these changes
Jan 17, 2025
emdneto
approved these changes
Jan 17, 2025
53 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Span context manager functions that use the
_agnosticcontextmanagerdecorator (likestart_as_current_span()) are currently of typeUnknownwhen type checking for python <3.10 with pyright. This was coming up in open-telemetry/opentelemetry-python-contrib#3192 (failed run).Also Fix #3836
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Contrib Repo Change?
Checklist: