types-contextvars
Typing stubs for contextvars
What it is and what it does
types-contextvars is a PEP 561 type stub package that supplies type annotations for Python's built-in contextvars module. It allows static type checkers and IDEs to understand the types and signatures of contextvars functions and classes, enabling developers to catch type errors during development rather than at runtime.
The package is generated from typeshed and was last tested with mypy 1.4.1, pyright 1.1.316, and pytype 2023.6.16. It has no runtime dependencies and installs as a pure-Python wheel. However, the package is explicitly unmaintained and will not receive updates, so its accuracy may drift as Python and type-checking tools evolve.
Use it for:
- Enable mypy or pyright to type-check code that uses contextvars.ContextVar for thread-safe context storage
- Provide IDE autocomplete and type hints when working with context variables in modern Python projects
- Validate type safety in async frameworks that rely on contextvars for managing request-scoped state
- Support legacy projects still using older type-checking tool versions that require explicit stubs
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides type stubs for Python's contextvars module, enabling static type checkers like mypy, pyright, and pytype to validate code using context variables.
Yes, if you use contextvars and need type checking with mypy, pyright, or pytype on Python versions up to those tested. However, be aware that the package is unmaintained—if you are on a newer Python version or type-checker version than those listed, the stubs may become inaccurate. For modern Python (3.7+), consider whether your type checker already includes contextvars stubs inline before installing.
Install
types-contextvars on PyPI
pip
pip install types-contextvarsuv
uv add types-contextvarspoetry
poetry add types-contextvarsInstalling types-contextvars
Before you install
Low friction installation as a pure-Python stub package with no runtime dependencies. However, the package is explicitly unmaintained and has not been updated since July 2023, so it will not receive fixes for new Python versions or type-checking tool changes.
License in practice
Licensed under Apache-2.0, a permissive open-source license that allows free use, modification, and distribution with minimal restrictions, making it safe to include in most projects.
Quickstart
pip install types-contextvars
# Then use in your code with type checking enabled:
import contextvars
my_var: contextvars.ContextVar[str] = contextvars.ContextVar('my_var')
This package is only useful when running a static type checker (mypy, pyright, pytype, or IDE type checking); it provides no runtime functionality.
Verify before relying
- Whether the stubs remain accurate for contextvars in current Python versions beyond those tested (mypy 1.4.1, pyright 1.1.316, pytype 2023.6.16)
- Whether unmaintained status will cause compatibility issues as type checkers evolve
Package facts
| License | Apache-2.0 license (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 1,134 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 222,896/month — #9,256 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: types_contextvars-2.4.7.3-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
types-typed-astProvides type stubs for the typed-ast package,…
permissive · top 15,000 on PyPI
types-appdirsProvides type stubs for the appdirs package to…
permissive · top 15,000 on PyPI
contextvarsProvides the PEP 567 contextvars module for…
permissive · top 5,000 on PyPI
types-DateTimeRangeProvides type stubs for the DateTimeRange…
permissive · top 15,000 on PyPI
aiocontextvarsProvides asyncio support for the contextvars…
permissive · top 15,000 on PyPI
types-urllib3Provides type stubs for urllib3 to enable…
permissive · top 1,000 on PyPI
types-dataclassesProvides type stubs for Python's dataclasses…
permissive · top 15,000 on PyPI
pytypePytype is a static type checker that infers…
permissive · top 5,000 on PyPI
types-babelProvides type stubs for the babel package,…
permissive · top 15,000 on PyPI
types-futuresProvides type stubs for the futures package,…
permissive · top 15,000 on PyPI