|
11 | 11 | from urllib.request import getproxies |
12 | 12 |
|
13 | 13 | try: |
14 | | - import brotli |
| 14 | + import brotli # type: ignore |
15 | 15 | except ImportError: |
16 | 16 | brotli = None |
17 | 17 |
|
|
24 | 24 | from sentry_sdk.worker import BackgroundWorker |
25 | 25 | from sentry_sdk.envelope import Envelope, Item, PayloadRef |
26 | 26 |
|
27 | | -from typing import TYPE_CHECKING |
| 27 | +from typing import TYPE_CHECKING, cast |
28 | 28 |
|
29 | 29 | if TYPE_CHECKING: |
30 | 30 | from typing import Any |
@@ -176,10 +176,11 @@ def _parse_rate_limits(header, now=None): |
176 | 176 | for limit in header.split(","): |
177 | 177 | try: |
178 | 178 | parameters = limit.strip().split(":") |
179 | | - retry_after, categories = parameters[:2] |
| 179 | + retry_after_val, categories = parameters[:2] |
180 | 180 |
|
181 | | - retry_after = now + timedelta(seconds=int(retry_after)) |
| 181 | + retry_after = now + timedelta(seconds=int(retry_after_val)) |
182 | 182 | for category in categories and categories.split(";") or (None,): |
| 183 | + category = cast(EventDataCategory, category) |
183 | 184 | if category == "metric_bucket": |
184 | 185 | try: |
185 | 186 | namespaces = parameters[4].split(";") |
@@ -580,7 +581,7 @@ def flush( |
580 | 581 | timeout, |
581 | 582 | callback=None, |
582 | 583 | ): |
583 | | - # type: (Self, float, Optional[Callable]) -> None |
| 584 | + # type: (Self, float, Optional[Callable[[int, float], None]]) -> None |
584 | 585 | logger.debug("Flushing HTTP transport") |
585 | 586 |
|
586 | 587 | if timeout > 0: |
|
0 commit comments