-
Notifications
You must be signed in to change notification settings - Fork 555
Migrate typing for opentelemetry files #4510
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
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
|
if profiler_id is None: | ||
return None | ||
|
||
8000 return {"profiler_id": profiler_id} | ||
|
||
|
||
def get_typed_attribute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helper function to get an attribute with a certain typecheck
@@ -1561,10 +1561,11 @@ def parse_url(url: str, sanitize: bool = True) -> ParsedUrl: | |||
) | |||
|
|||
|
|||
def is_valid_sample_rate(rate: Any, source: str) -> bool: | |||
def is_valid_sample_rate(rate: Any, source: str) -> Optional[float]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returns the validated float sample_rate
to simplify all the float casts around
80dd79f
to
612f157
Compare
612f157
to
554c391
Compare
5a5ca51
to
3f2b752
Compare
* 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
* 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
* 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
* 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
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
is_valid_sample_rate
to return the validated floatvalidate_scopes
helper method to validate the scopes entry on the context and return the narrowed typeget_typed_attribute
helper method to narrow the type on getting attributes from otel