skillfed

types-contextvars

Typing stubs for contextvars

types-contextvars v2.4.7.3 222.9K downloads/30d#9,256 on PyPI5,108
Permissive license Apache-2.0 license Active released

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-contextvars

uv

uv add types-contextvars

poetry

poetry add types-contextvars

Installing 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

License :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Typing :: Stubs Only

Tags

contextvars type stubstyping stubs for contextvarsmypy contextvars typesstatic type checking context variablesPEP 561 type stubspyright contextvars support
type-stubsunmaintained

More Software Development packages