jaraco.context
Useful decorators and context managers
Decision gist · record as of 2026-08-14
Yes. jaraco.context is a lightweight, actively maintained utility library with no security issues, a permissive license, and low install friction. It's worth installing if you regularly use exception traps, context managers for directory changes, or tarball extraction in your code—it reduces boilerplate and improves readability. Skip it if your codebase doesn't use these patterns.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low install friction with a single runtime dependency (backports.tarfile).
- The package is actively maintained with a recent release and has been stable since its initial release in 2014.
License · maintenance · safety
MIT (permissive) — MIT license permits use in commercial and private projects with minimal restrictions; attribution required.
last release 2026-03-20 (147 days) · last repo commit 2026-05-03 · 3 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 215,370,078 downloads/mo, #190 on PyPI
Alternatives
Verify before relying
pip install jaraco.context
from jaraco.context import ExceptionTrap
with ExceptionTrap() as trap:
result = some_function()
if trap.exception:
handle_error(trap.exception)- Whether backports.tarfile is a compiled dependency or pure Python.
- Performance characteristics when handling large tarballs or many context switches.
What it is and what it does
jaraco.context is a collection of decorators and context managers that simplify common control-flow patterns in Python. It wraps exception handling, directory changes, and resource cleanup into reusable, composable utilities. The package's main components include ExceptionTrap for capturing and acting on exceptions, suppress as a decorator form of contextlib.suppress, on_interrupt for CLI keyboard handling, pushd for temporary directory changes, tarball for downloading and extracting archives, and null for conditional context symmetry.
The package is designed for developers who want to reduce boilerplate around exception handling and resource management. It's particularly useful in CLI tools, testing code, and applications that work with temporary files or network resources. With a permissive MIT license, active maintenance, and no known vulnerabilities, it presents a low-risk addition to projects targeting Python 3.10+.
Use it for
- Wrap function calls to convert exceptions into boolean outcomes using ExceptionTrap with passes/raises decorators.
- Suppress specific exceptions as a decorator instead of using contextlib.suppress in a with statement.
- Handle KeyboardInterrupt gracefully in CLI entry points using the on_interrupt decorator.
- Temporarily change working directory for a code block using pushd, then restore the original directory.
- Download, extract, and work with remote tarballs while ensuring cleanup with the tarball context manager.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
jaraco.context is a lightweight, actively maintained utility library with no security issues, a permissive license, and low install friction. It's worth installing if you regularly use exception traps, context managers for directory changes, or tarball extraction in your code—it reduces boilerplate and improves readability. Skip it if your codebase doesn't use these patterns.
Install
jaraco-context on PyPI
Before you install
Low install friction with a single runtime dependency (backports.tarfile). The package is actively maintained with a recent release and has been stable since its initial release in 2014.
Requires Python 3.10 or later.
License in practice
MIT license permits use in commercial and private projects with minimal restrictions; attribution required.
Quickstart
pip install jaraco.context
from jaraco.context import ExceptionTrap
with ExceptionTrap() as trap:
result = some_function()
if trap.exception:
handle_error(trap.exception)
Verify before relying
- Whether backports.tarfile is a compiled dependency or pure Python.
- Performance characteristics when handling large tarballs or many context switches.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagebackports.tarfile |
| Maintenance | Actively maintained 147 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 215,370,078 / month, #190 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: Only |
Evidence: jaraco_context-6.1.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “context managers decorators”
- jaraco.contextProvides decorators and context managers for exception handling,…
- aiotoolsaiotools provides idiomatic asyncio utilities for structured…
- stopitProvides context managers and decorators to enforce timeouts on code…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
Provides additional functional programming utilities beyond Python's standard library functools, including decorators and higher-order functions for common patterns.
Install only if you have a specific need for the additional functools it provides—it's a specialized library, not a general dependency.
Provides context managers and decorators to enforce timeouts on code blocks and function calls, and raise exceptions asynchronously in other threads.
Provides utility functions for working with Python class constructs and class-related patterns.
Provides command-line and user-interface utilities for Python developers, built on jaraco.classes, jaraco.text, named, and typer.
Interrupts long-running Python code by raising an exception after a specified timeout, using signal-based interruption on the main thread.
Provides function decorators for retrying operations with configurable backoff strategies when exceptions occur or predicates are met, supporting both synchronous and asynchronous code.
Install it if you need to add resilience to functions that interact with unreliable external resources.
See also async-interrupt · backoff · undecorated · redo