sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

Migrate typing for core files

Open sl0thentr0py opened this issue 7 months ago • 3 comments

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 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

sl0thentr0py avatar Jun 20 '25 12:06 sl0thentr0py

Codecov Report

Attention: Patch coverage is 97.98032% with 39 lines in your changes missing coverage. Please review.

Project coverage is 84.86%. Comparing base (06ef70c) to head (7bfc6a0). Report is 1 commits behind head on potel-base.

:white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/integrations/gcp.py 0.00% 9 Missing :warning:
sentry_sdk/integrations/aws_lambda.py 73.68% 5 Missing :warning:
sentry_sdk/integrations/clickhouse_driver.py 64.28% 2 Missing and 3 partials :warning:
sentry_sdk/transport.py 92.00% 3 Missing and 1 partial :warning:
sentry_sdk/utils.py 97.24% 2 Missing and 1 partial :warning:
sentry_sdk/integrations/spark/spark_driver.py 94.87% 2 Missing :warning:
sentry_sdk/scope.py 98.29% 2 Missing :warning:
sentry_sdk/_compat.py 80.00% 1 Missing :warning:
sentry_sdk/integrations/asgi.py 93.75% 1 Missing :warning:
sentry_sdk/integrations/atexit.py 83.33% 1 Missing :warning:
... and 6 more
Additional details and impacted files
@@              Coverage Diff               @@
##           potel-base    #4500      +/-   ##
==============================================
+ Coverage       84.84%   84.86%   +0.01%     
==============================================
  Files             144      144              
  Lines           14882    15005     +123     
  Branches         2362     2374      +12     
==============================================
+ Hits            12627    12734     +107     
- Misses           1533     1541       +8     
- Partials          722      730       +8     
Files with missing lines Coverage Δ
sentry_sdk/_init_implementation.py 100.00% <100.00%> (ø)
sentry_sdk/_log_batcher.py 79.76% <100.00%> (+0.24%) :arrow_up:
sentry_sdk/_lru_cache.py 100.00% <100.00%> (ø)
sentry_sdk/_queue.py 60.00% <100.00%> (ø)
sentry_sdk/_werkzeug.py 50.00% <100.00%> (+1.85%) :arrow_up:
sentry_sdk/ai/monitoring.py 88.88% <100.00%> (+0.15%) :arrow_up:
sentry_sdk/ai/utils.py 85.71% <100.00%> (+0.71%) :arrow_up:
sentry_sdk/api.py 96.77% <100.00%> (+0.03%) :arrow_up:
sentry_sdk/attachments.py 100.00% <100.00%> (ø)
sentry_sdk/client.py 84.88% <100.00%> (ø)
... and 124 more

codecov[bot] avatar Jun 20 '25 19:06 codecov[bot]

@sentrivana fixed the casts and needed some changes to fix the resulting problems which were actually bad type signatures so fixed those too

sl0thentr0py avatar Jun 23 '25 13:06 sl0thentr0py

also I will keep this draft and stack the other PRs on top and merge all at once into potel-base at the end

sl0thentr0py avatar Jun 23 '25 13:06 sl0thentr0py