Registry / type-stubs / types-gevent

types-gevent

JSON →
library26.8.0.20260811pypypi✓ verified 23d ago

types-gevent provides external type annotations (stubs) for the gevent library. It enables static type checkers like MyPy and Pyright to perform type checking, inference, and autocompletion for code that uses gevent. As part of the typeshed project, its releases are automatically generated and follow a versioning scheme tied to the gevent runtime package version.

pip install types-gevent
INSTALL
IMPORT
SIG · TYPES-GEVENT
T
types-gevent
type-stubspythonv26.8.0.20260811
Install
1.7s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.8.0.20260811 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

gevent-stubs
import gevent_stubs
import gevent-stubs

This example demonstrates how types-gevent provides type hints for the gevent library. After installing both 'gevent' and 'types-gevent', a type checker like MyPy can analyze the code. The type hints for `fetch_data` and `process_urls` will be checked, and `gevent.spawn` and `gevent.joinall` will have their expected types available for static analysis.

import gevent import gevent.monkey import typing gevent.monkey.patch_all() def fetch_data(url: str) -> str: """Simulates fetching data asynchronously.""" gevent.sleep(0.1) # Simulate I/O delay return f"Data from {url}" def process_urls(urls: typing.List[str]) -> typing.List[str]: greenlets = [gevent.spawn(fetch_data, url) for url in urls] gevent.joinall(greenlets) results = [g.value for g in greenlets] return results if __name__ == "__main__": urls_to_process = ["http://example.com/1", "http://example.com/2"] processed_data = process_urls(urls_to_process) print(f"Processed: {processed_data}") # To run type checking, save this as e.g., 'main.py' and run: # mypy main.py
Debug
Known issues
breakingType stubs are version-specific. Installing 'types-gevent' for 'gevent==X.Y' alongside a different version of 'gevent' (e.g., 'gevent==A.B' where A.B != X.Y) can lead to incorrect type checking errors or missed type issues. The 'types-gevent' package version `X.Y.Z.YYYYMMDD` indicates it targets `gevent==X.Y.*`.
fix
Ensure that the major and minor version numbers of `types-gevent` (e.g., '25.9' from '25.9.0.20260408') match or are compatible with your installed `gevent` runtime version. Pin both `gevent` and `types-gevent` to compatible versions in your project's dependencies.
affects: All versions
gotchaStub packages like 'types-gevent' provide static type information only; they do not include any runtime code or functionality. Installing 'types-gevent' without the actual 'gevent' library will not make 'gevent' available for execution.
fix
Always install the 'gevent' runtime library (`pip install gevent`) in addition to its type stubs (`pip install types-gevent`) for your application to function correctly.
affects: All versions
gotchaWhen using `gevent.monkey.patch_all()`, the patching must occur as early as possible in your application's lifecycle, typically at the very beginning of your main script. Delaying patching, especially after other standard library modules (e.g., `concurrent.futures`, `threading`) have been imported, can result in those modules retaining their original blocking behavior or lead to conflicts.
fix
Place `gevent.monkey.patch_all()` at the top of your application's entry point file before any other imports that might use standard library I/O or concurrency primitives.
affects: All versions of gevent utilizing monkey patching
gotchaGevent is designed for I/O-bound concurrency, not CPU-bound parallelism. Running CPU-intensive tasks within a greenlet will block the entire event loop, preventing other greenlets from executing and negating the benefits of cooperative multitasking.
fix
Offload CPU-intensive operations to separate processes or threads (e.g., using `multiprocessing` or `concurrent.futures.ThreadPoolExecutor` where appropriate) to avoid blocking the gevent event loop.
affects: All versions
gotchaCombining `gevent` with Python's built-in `multiprocessing` module can introduce complex issues and is generally discouraged without careful management. Specifically, after forking on POSIX systems, `gevent`'s internal state in the child process can be ill-posed, leading to unexpected behavior.
fix
If multiprocessing is necessary, carefully review the `gevent` documentation on `gevent.subprocess` and `multiprocessing` interactions. Consider using process pools or alternative strategies for multi-core utilization that are compatible with `gevent`'s cooperative concurrency model.
affects: All versions
Upgrade
Version history
26.8.0.20260811latest on PyPI · released Aug 11, 2026
Audit
Dependencies
geventrequiredtypes-gevent provides type hints for the gevent library; gevent is required at runtime for any practical use of the stubs.
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
types-gevent — pip install types-gevent · libregistry