| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
BaseProvider.in_subsegment_async was decorated with @contextmanager and annotated to return Generator[BaseSegment, None, None], declaring a synchronous context manager. It is entered with async with by Tracer._decorate_async_function, by the documented escape hatch for concurrent async functions, and by the default X-Ray provider. Remove the decorator and annotate the return type as AbstractAsyncContextManager[BaseSegment] so correct code type checks without a cast. No runtime change, the abstract method body is only a docstring. Closes aws-powertools#8365
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for working on this @vishwakt !
Sorry, something went wrong.
|
Tick the box to add this pull request to the merge queue (same as @mergifyio queue).
|
Sorry, something went wrong.
|
Sorry, something went wrong.
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
Sorry, something went wrong.
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
Sorry, something went wrong.
Codecov Report❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
@@ Coverage Diff @@
## develop #8367 +/- ##
========================================
Coverage 96.63% 96.64%
========================================
Files 296 296
Lines 14765 14764 -1
Branches 1245 1245
========================================
Hits 14268 14268
+ Misses 362 361 -1
Partials 135 135 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue number: closes #8365
Summary
Changes
BaseProvider.in_subsegment_async was decorated with @contextmanager and annotated to return Generator[BaseSegment, None, None], which declares a synchronous context manager. The method is entered with async with in three places: Tracer._decorate_async_function, the documented escape hatch for concurrent async functions in capture_method, and user code targeting the default X-Ray provider, whose in_subsegment_async returns an asynchronous context manager.
This PR removes the @contextmanager decorator from the abstract method and changes the return annotation to AbstractAsyncContextManager[BaseSegment]. No runtime change, the abstract method body is only a docstring.
User experience
Before, mypy rejects correct code:
After, the same code type checks without a cast. Verified with mypy on the snippet from the issue, on aws_lambda_powertools/tracing, and on examples/tracer/src/capture_method_async_concurrency.py. All unit tests in tests/unit/test_tracing.py pass.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.