Commit b392bc4
refactor: Simplify and deduplicate async transport code
Major cleanup that removes ~390 lines while preserving all functionality:
Architecture:
- Always define AsyncHttpTransport as a real class (not aliased to
HttpTransport when deps missing). Raises RuntimeError in __init__
instead. This eliminates the isinstance aliasing bug and removes
most type: ignore annotations.
- Add _is_async_transport() helper to _Client, replacing 4 repeated
isinstance checks.
Deduplication in transport.py:
- Extract _get_httpcore_pool_options() into HttpTransportCore — shared
by AsyncHttpTransport and Http2Transport (SSL, certs, socket opts).
- Extract _resolve_proxy() into HttpTransportCore — shared proxy URL
resolution logic.
- Extract _timeout_extensions property — shared timeout config dict.
- Extract _get_httpcore_header_value() module function — shared
case-insensitive header lookup for httpcore responses.
- Enable HTTP/2 in AsyncHttpTransport when DSN scheme is HTTPS.
Simplification in client.py:
- Use _batchers tuple property in _flush_components/_close_components
to avoid repeating the same None-check pattern for each batcher.
Test cleanup:
- Extract PROXY_TESTCASES and SOCKS_PROXY_TESTCASES constants shared
between sync and async proxy tests (-300 lines).
- Add _make_async_transport_options() helper for make_transport tests.
- Remove section separator comments.
- Trim Worker ABC docstrings to one-liners.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent b990610 commit b392bc4
File tree
6 files changed
+519
-909
lines changed- sentry_sdk
- integrations
- tests
6 files changed
+519
-909
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
1010 | 1009 | | |
1011 | 1010 | | |
1012 | 1011 | | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1013 | 1024 | | |
1014 | 1025 | | |
1015 | 1026 | | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
| 1027 | + | |
| 1028 | + | |
1022 | 1029 | | |
1023 | 1030 | | |
1024 | 1031 | | |
1025 | 1032 | | |
1026 | 1033 | | |
1027 | 1034 | | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
| 1035 | + | |
| 1036 | + | |
1034 | 1037 | | |
1035 | 1038 | | |
1036 | 1039 | | |
| |||
1042 | 1045 | | |
1043 | 1046 | | |
1044 | 1047 | | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
| 1048 | + | |
1048 | 1049 | | |
1049 | 1050 | | |
1050 | 1051 | | |
| |||
1067 | 1068 | | |
1068 | 1069 | | |
1069 | 1070 | | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
| 1071 | + | |
1074 | 1072 | | |
1075 | 1073 | | |
1076 | 1074 | | |
| |||
1095 | 1093 | | |
1096 | 1094 | | |
1097 | 1095 | | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
| 1096 | + | |
1101 | 1097 | | |
1102 | 1098 | | |
1103 | 1099 | | |
| |||
1121 | 1117 | | |
1122 | 1118 | | |
1123 | 1119 | | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
| 1120 | + | |
1128 | 1121 | | |
1129 | 1122 | | |
1130 | 1123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 71 | + | |
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
| |||
0 commit comments