{"categories":[{"label":"Software Development","url":"https://skillfed.io/packages/category/software-development/13"}],"enrichment":{"capability":"Conditionally apply a context manager to a code block based on a boolean condition, eliminating the need to duplicate the block's body in if/else branches.","skillfed_tags":["context-manager","async-support","typed"],"use_cases":["Conditionally suppress signals or exceptions in a code block depending on runtime state.","Apply a database transaction context manager only when needed, executing the same code path either way.","Optionally enable timing or profiling instrumentation around a block based on a debug flag.","Conditionally acquire a lock or semaphore depending on whether concurrent access is expected.","Skip file-locking or temporary-directory setup in certain execution modes while keeping the main logic unified."],"what_it_does":"conditional is a lightweight context manager that wraps another context manager and enters it only when a condition is true, while always executing the body of the with-block. Instead of writing separate if/else branches with duplicated code\u2014one branch with the context manager and one without\u2014you pass a boolean condition and the context manager to conditional, and it handles the logic.\n\nThe package supports both synchronous and asynchronous context managers, includes full type annotations for IDE and type-checker support, and has no external dependencies. It is stable (Development Status 5), actively maintained, and suitable for any code path where you want to conditionally apply resource management, signal handling, or other context-dependent setup without code duplication.","worth_installing":"Yes. This is a stable, actively maintained, zero-dependency utility that solves a genuine code-organization problem. If you write context managers and find yourself duplicating code blocks to conditionally apply them, conditional eliminates that duplication cleanly. The permissive license and type annotations add no friction."},"id":"conditional","links":{"html":"https://skillfed.io/packages/conditional","md":"https://skillfed.io/packages/conditional.md","pypi":"https://pypi.org/project/conditional/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2026-07-04","license_spdx":null,"license_treatment":"permissive","name":"conditional","python_support":"supports_current","summary":"Conditionally enter a context manager"},"popularity":{"monthly_downloads":233637,"position":9036,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"2.2"}
