Registry / type-stubs / types-retry

types-retry

JSON →
library0.9.9.20260408pypypi✓ verified 25d ago

The `types-retry` package provides PEP 561 compatible type stubs for the `retry` library (pypi.org/project/retry), enabling static type checking for code that implements retry logic. As an auto-generated part of the `typeshed` project, it receives regular updates to reflect the API of the `retry` library. The current version is 0.9.9.20260408, with releases typically tied to updates in the upstream `retry` library or `typeshed` itself.

pip install retry
INSTALL
IMPORT
SIG · TYPES-RETRY
T
types-retry
type-stubspythonv0.9.9.20260408
Install
1.6s avg
Import
52ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.9.20260408 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.054s · 66.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.050s · 18MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

retry
from retry import retry
This is the primary decorator for adding retry logic to functions.
retry_call
from retry import retry_call
Used to call a function with retry logic directly, without a decorator.

This quickstart demonstrates how to apply the `@retry` decorator to an unreliable function. It configures the decorator to retry specifically on `ConnectionError` exceptions, up to 3 times, with a 2-second delay between attempts. Without `types-retry`, type checkers would have limited understanding of the decorator's effects on the function signature; with it, they can provide more accurate analysis.

import random from retry import retry import os # Example function that might fail def unreliable_service_call() -> str: if random.random() < 0.7: # 70% chance of failure raise ConnectionError("Failed to connect to service!") return "Service data retrieved successfully!" # Decorate the function with retry logic @retry(exceptions=ConnectionError, tries=3, delay=2000) # Retry 3 times, with 2-second delay def call_with_retry() -> str: print("Attempting service call...") return unreliable_service_call() if __name__ == "__main__": try: result = call_with_retry() print(result) except Exception as e: print(f"All retry attempts failed: {e}")
Debug
Known issues
gotchaThe `types-retry` package only provides type hints. You must separately install the actual `retry` runtime library (`pip install retry`) for your code to function. Forgetting the runtime library is a common oversight.
fix
Ensure both `pip install retry` and `pip install types-retry` are executed in your environment.
affects: All versions
gotchaThere are multiple Python libraries offering retry functionality (e.g., `retry`, `retrying`, `tenacity`). `types-retry` specifically provides stubs for the `retry` library (often associated with `github.com/invl/retry`). Ensure you are using the correct runtime library if you are relying on these type stubs.
fix
Verify that your `import` statements and usage align with the `retry` library, not `retrying` or `tenacity`.
affects: All versions
gotchaBy default, the `@retry` decorator retries indefinitely if no `tries` parameter is specified. This can lead to infinite loops in case of persistent errors, consuming resources or hanging applications.
fix
Always set a `tries` limit (e.g., `tries=3`) or a `stop` condition (e.g., `stop_max_delay`) to prevent infinite retries.
affects: All versions of `retry` (runtime library)
breakingAs part of `typeshed`, `types-retry` aims to provide accurate annotations for specific versions of the `retry` library (e.g., `retry==0.9.*` for `types-retry==0.9.*`). Major updates to the `retry` library's API might cause type-checking failures if your `types-retry` version is not compatible with your installed `retry` version.
fix
Pin your `types-retry` version to match the expected `retry` library version, or explicitly manage compatibility. For example, if you use `retry==0.9.x`, use `types-retry>=0.9.0,<1.0.0` or `types-retry==0.9.9.20260408` (specific release of stubs).
affects: All versions
gotchaType changes in stub packages can sometimes cause type checkers to fail even if the runtime code remains unchanged. `typeshed` strives to minimize this, but it can occur. Older `mypy` versions might also misinterpret newer `typeshed` features, silently losing type precision.
fix
Consider pinning specific versions of `types-retry` and your type checker (e.g., `mypy`) in your development environment to ensure consistent type checking results.
affects: All versions, especially with older type checkers
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'retry'
The actual 'retry' library, which `types-retry` provides type stubs for, is not installed. `types-retry` does not provide the runtime functionality.
fix
pip install retry
error: Cannot find implementation or library stub for module named 'retry'
A type checker (like MyPy or Pyright) cannot locate the type stubs for the 'retry' library, which are provided by the `types-retry` package.
fix
pip install types-retry
error: Call to untyped function "retry"
MyPy is unable to find or apply type information for the `retry` function, typically because the `types-retry` stub package is missing or not correctly accessible to MyPy.
fix
pip install types-retry
error: Argument "delay" to "retry" has incompatible type "float"; expected "int"
A type checker detected that an argument passed to the `retry` function (e.g., `delay`) does not match the expected type defined in the `types-retry` stubs, potentially due to incorrect usage or a version mismatch.
fix
Consult the `retry` library documentation for the correct argument types. Ensure your `retry` and `types-retry` package versions are compatible. Adjust the argument type in your code (e.g., `delay=int(0.5)`).
Upgrade
Version history
0.9.9.20260408latest on PyPI · released Apr 8, 2026
Audit
Dependencies
retryrequiredProvides type hints for the runtime 'retry' library.
Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources