Backwards-compatibility for the old retries format.
(
cls,
retries: Retry | bool | int | None,
redirect: bool | int | None = True,
default: Retry | bool | int | None = None,
)
| 289 | |
| 290 | @classmethod |
| 291 | def from_int( |
| 292 | cls, |
| 293 | retries: Retry | bool | int | None, |
| 294 | redirect: bool | int | None = True, |
| 295 | default: Retry | bool | int | None = None, |
| 296 | ) -> Retry: |
| 297 | """Backwards-compatibility for the old retries format.""" |
| 298 | if retries is None: |
| 299 | retries = default if default is not None else cls.DEFAULT |
| 300 | |
| 301 | if isinstance(retries, Retry): |
| 302 | return retries |
| 303 | |
| 304 | redirect = bool(redirect) and None |
| 305 | new_retries = cls(retries, redirect=redirect) |
| 306 | log.debug("Converted retries value: %r -> %r", retries, new_retries) |
| 307 | return new_retries |
| 308 | |
| 309 | def get_backoff_time(self) -> float: |
| 310 | """Formula for computing the current backoff |