-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError from opentelemetry.context.contextvars_context in detach #4163
Comments
Why do you think this should handled instead of delegating to mypy? |
Hi, afaik, the related line here is ignoring mypy.
Due to this comment, mypy cannot detect TypeError. If you are suggesting to uncomment the ignore, I'm ok, the draft PR is just my initial proposal. |
Missed that, thanks. Yeah, I think it would make sense to add type annotations here if feasible |
I added type annotations - could you have a check on the latest PR of this issue? |
@xrmx I managed to reproduce a problem with a 'None' token using a partially instrumented celery (sender not instrumented, worker instrumented) as seen above. This causes the context.detach to fail. I'm not sure if the fix is simply to to check if the token is not None before calling detach ? |
Describe your environment
Python version: 3.12.4
SDK version: 1.25.0
API version: 1.25.0
What happened?
TypeError from opentelemetry.context.contextvars_context in detach.
The function detach expected an instance of Token, but it got None.
Thus, it fails to detach context.
Steps to Reproduce
Pass None to _RUNTIME_CONTEXT.detach
Expected Result
This kind of error should be elaborated, without avoiding mypy
Actual Result
TypeError occurs
Additional context
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: