Migrate typing for opentelemetry files#4510
Merged
sl0thentr0py merged 2 commits intoneel/typingfrom Jun 25, 2025
Merged
Conversation
4b736e1 to
80dd79f
Compare
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## neel/typing #4510 +/- ##
===============================================
- Coverage 84.68% 84.67% -0.01%
===============================================
Files 144 144
Lines 14847 14854 +7
Branches 2370 2372 +2
===============================================
+ Hits 12573 12578 +5
- Misses 1544 1545 +1
- Partials 730 731 +1
|
sl0thentr0py
commented
Jun 24, 2025
| return {"profiler_id": profiler_id} | ||
|
|
||
|
|
||
| def get_typed_attribute( |
Member
Author
There was a problem hiding this comment.
helper function to get an attribute with a certain typecheck
|
|
||
|
|
||
| def is_valid_sample_rate(rate: Any, source: str) -> bool: | ||
| def is_valid_sample_rate(rate: Any, source: str) -> Optional[float]: |
Member
Author
There was a problem hiding this comment.
returns the validated float sample_rate to simplify all the float casts around
80dd79f to
612f157
Compare
612f157 to
554c391
Compare
sl0thentr0py
commented
Jun 24, 2025
sl0thentr0py
commented
Jun 24, 2025
sentrivana
approved these changes
Jun 25, 2025
5a5ca51 to
3f2b752
Compare
sl0thentr0py
added a commit
that referenced
this pull request
Jun 25, 2025
* remove casts * generalize `is_valid_sample_rate` to return the validated float * added a `validate_scopes` helper method to validate the scopes entry on the context and return the narrowed type * added a `get_typed_attribute` helper method to narrow the type on getting attributes from otel * fix a flaky test on gevent
sl0thentr0py
added a commit
that referenced
this pull request
Jun 25, 2025
* remove casts * generalize `is_valid_sample_rate` to return the validated float * added a `validate_scopes` helper method to validate the scopes entry on the context and return the narrowed type * added a `get_typed_attribute` helper method to narrow the type on getting attributes from otel * fix a flaky test on gevent
sl0thentr0py
added a commit
that referenced
this pull request
Jun 26, 2025
* remove casts * generalize `is_valid_sample_rate` to return the validated float * added a `validate_scopes` helper method to validate the scopes entry on the context and return the narrowed type * added a `get_typed_attribute` helper method to narrow the type on getting attributes from otel * fix a flaky test on gevent
Merged
sl0thentr0py
added a commit
that referenced
this pull request
Jun 27, 2025
* remove casts * generalize `is_valid_sample_rate` to return the validated float * added a `validate_scopes` helper method to validate the scopes entry on the context and return the narrowed type * added a `get_typed_attribute` helper method to narrow the type on getting attributes from otel * fix a flaky test on gevent
sl0thentr0py
added a commit
that referenced
this pull request
Jun 30, 2025
extracted from https://github.com/getsentry/sentry-python/pull/4487/files with lots of manual fixes * migrate old style `# type: bla` to inline types * most importantly use [`__future__.annotations`](https://peps.python.org/pep-0563/#enabling-the-future-behavior-in-python-3-7) so that we can simply use forward annotations without wrapping them in strings like we did before, this simplifies things substantially * also guard only things that shouldn't be imported under `TYPE_CHECKING`, in the future it seems we should avoid using `TYPE_CHECKING` completely * #4510 * #4522 * #4529 * #4530 * #4532 * #4533 * #4534 closes #2585
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.
is_valid_sample_rateto return the validated floatvalidate_scopeshelper method to validate the scopes entry on the context and return the narrowed typeget_typed_attributehelper method to narrow the type on getting attributes from otel