Skip to main content

contextlib-ext - extensions for contextlib

Build Status

contextlib-ext is a complimentary library for contextlib, it provides a following helpers:

suppress as a decorator

suppress can be used as a decorator

from contextlib_ext import suppress

@suppress(Exception)
def phony_func():
    raise ValueError

phony_func()
print("No exceptions")

@asynccontextmanager creates decorator

@asynccontextmanager creates context manager that can be used as a decorator (contextlib.contextmanager already supports it)

from contextlib_ext import asynccontextmanager

@asynccontextmanager
async def mymanager():
    yield

# The same as contextlib.asynccontextmanager
async with mymanager():
    pass

# This also works
@mymanager
async def myfunc():
    pass

async_suppress

async_suppress - the same as suppress, but async

from contextlib_ext import async_suppress

try:
  async with async_suppress(Exception):
      raise ValueError
except Exception:
  assert False  # never happens
else:
  print("No exceptions")

# Works as decorator too

@async_suppress(Exception)
async def phony_func():
    raise ValueError

phony_func()
print("No exceptions")

Metadata

Release files for contextlib-ext 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contextlib-ext 0.0.0
File Size Uploaded Provenance
contextlib-ext-0.0.0.tar.gz 2.3 kB Without provenance Details

Release files / contextlib-ext-0.0.0.tar.gz

Download URL contextlib-ext-0.0.0.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
115ab1a9ae858725bd586f917496acec764761533219338a426f8f3bc27ba66b
BLAKE2b-256 checksum
How to use checksums
5ef5ce0f732fd534e89740e7d70078a97618f6be039f959e1bf53bf175591969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

Security for contextlib-ext 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page