Install & Compatibility
Where this runs
tested against v3.5.0.20260518 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 23.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 21MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
greenlet
✓ import greenlet
You import the runtime `greenlet` library; types-greenlet provides annotations for it implicitly to type checkers.
greenlet.greenlet
✓ from greenlet import greenlet
greenlet.getcurrent
✓ from greenlet import getcurrent
This example demonstrates basic usage of the `greenlet` library. When `types-greenlet` is installed, a static type checker will understand the types associated with `greenlet.greenlet`, `greenlet.getcurrent()`, and their methods, providing better analysis and error detection without needing direct imports from `types-greenlet` itself.
import greenlet
def worker_function(name: str) -> str:
print(f"Worker {name} started.")
# Simulate some work, then switch back to parent
result = f"Hello from {name}!"
parent = greenlet.getcurrent().parent
if parent:
return parent.switch(result)
return result
def main_function():
main = greenlet.getcurrent()
g1 = greenlet.greenlet(worker_function)
g2 = greenlet.greenlet(worker_function)
print("Main function: Switching to g1")
res1 = g1.switch("Alice")
print(f"Main function: Received {res1}")
print("Main function: Switching to g2")
res2 = g2.switch("Bob")
print(f"Main function: Received {res2}")
print("Main function: All done.")
if __name__ == "__main__":
main_function()
# To verify type checking (requires mypy installed):
# Save this code as `example.py`
# Run `mypy example.py` in your terminal. With types-greenlet installed, it should pass without errors for greenlet-specific types.
Debug
Known issues
gotchaTypeshed stubs, including types-greenlet, only provide type annotations for static analysis and do not add any runtime behavior or functionality to the actual `greenlet` library. They are solely for type checkers.fixUnderstand that types-greenlet is a development dependency for type checking, not a runtime dependency.
affects: All versions
breakingAny version bump of `types-greenlet` (or any typeshed stub package) can potentially introduce changes that might cause your code to fail type checks, even if the runtime library's API hasn't changed. This is due to evolving type definitions or stricter annotations within typeshed.fixCarefully manage stub package versions. It's recommended to either use the same version bounds as the runtime `greenlet` package (e.g., `types-greenlet~=X.Y`) or pin the stubs to a known-good version and update periodically (e.g., `types-greenlet==X.Y.Z.YYYYMMDD`).
affects: All versions
gotchaThe `types-greenlet` package provides stubs specifically for the `greenlet` library. While `gevent` builds upon `greenlet`, it introduces its own `Greenlet` class and API. Using `types-greenlet` for `gevent` code might lead to incorrect or incomplete type checking, as it won't cover `gevent`-specific abstractions.fixFor `gevent` applications, look for `types-gevent` if available, or rely on any inline types provided by `gevent` itself.
affects: All versions
deprecatedIf the `greenlet` library were to start shipping its own inline type annotations (via a `py.typed` file), the external stubs provided by `types-greenlet` might eventually become obsolete and could be removed from typeshed after a transition period.fixStay informed about `greenlet`'s typing strategy. If it adopts inline types, `types-greenlet` may no longer be necessary or recommended.
affects: Future versions of greenlet, if it adds inline types.
Upgrade
Version history
3.5.0.20260518latest on PyPI · released May 18, 2026
Audit
Dependencies
greenletrequiredProvides runtime functionality; types-greenlet only provides type annotations for it.
mypyoptionalA common static type checker that utilizes these stubs.
pyrightoptionalAnother common static type checker that utilizes these stubs.