vendor_fabric._optional

Optional dependency utilities.

This module provides utilities for checking optional dependencies and providing helpful error messages when they’re missing.

Usage: from vendor_fabric._optional import require_extra, is_available

# Check if available (returns bool)
if is_available("boto3"):
    import boto3

# Require with helpful error (raises ImportError)
require_extra("boto3", "aws")  # -> "Install with: pip install vendor-fabric[aws]"

Module Contents

Functions

is_available

Check if a package is available for import.

get_extra_for_package

Get the extra name for a package.

require_extra

Import a package, raising helpful error if missing.

require_any

Import the first available package from a list.

get_extra_for_connector

Get the optional dependency extra for a connector.

get_connector_requirements

Get package imports required by a connector.

get_missing_connector_requirements

Get missing package imports for a connector.

get_connector_install_command

Get the pip install command for a connector extra.

is_connector_available

Check if a connector’s dependencies are available.

get_available_connectors

Get list of connectors with available dependencies.

require_connector

Ensure a connector’s dependencies are available.

Data

API

vendor_fabric._optional.PACKAGE_TO_EXTRA: dict[str, str] = None
vendor_fabric._optional.PACKAGE_INSTALL_HINTS: dict[str, str] = None
vendor_fabric._optional.is_available(package: str) bool

Check if a package is available for import.

Args: package: Package name to check (e.g., “boto3”, “googleapiclient”)

Returns: True if package can be imported, False otherwise

vendor_fabric._optional.get_extra_for_package(package: str) extended_data.containers.ExtendedString | None

Get the extra name for a package.

Args: package: Package name

Returns: Extra name or None if not mapped

vendor_fabric._optional.require_extra(package: str, extra: str | None = None) Any

Import a package, raising helpful error if missing.

Args: package: Package name to import extra: Optional extra name override (auto-detected if not provided)

Returns: The imported module

Raises: ImportError: With helpful install instructions if package is missing

vendor_fabric._optional.require_any(*packages: str, extra: str) Any

Import the first available package from a list.

Args: *packages: Package names to try (in order) extra: Extra name for error message

Returns: The first successfully imported module

Raises: ImportError: If none of the packages are available

vendor_fabric._optional.CONNECTOR_REQUIREMENTS: dict[str, list[str]] = None
vendor_fabric._optional.CONNECTOR_EXTRAS: dict[str, str] = None
vendor_fabric._optional.get_extra_for_connector(connector: str) extended_data.containers.ExtendedString | None

Get the optional dependency extra for a connector.

vendor_fabric._optional.get_connector_requirements(connector: str) extended_data.containers.ExtendedList[extended_data.containers.ExtendedString]

Get package imports required by a connector.

vendor_fabric._optional.get_missing_connector_requirements(connector: str) extended_data.containers.ExtendedList[extended_data.containers.ExtendedString]

Get missing package imports for a connector.

vendor_fabric._optional.get_connector_install_command(connector: str) extended_data.containers.ExtendedString | None

Get the pip install command for a connector extra.

vendor_fabric._optional.is_connector_available(connector: str) bool

Check if a connector’s dependencies are available.

Args: connector: Connector name (e.g., “aws”, “meshy”)

Returns: True if all required packages are available

vendor_fabric._optional.get_available_connectors() extended_data.containers.ExtendedList[extended_data.containers.ExtendedString]

Get list of connectors with available dependencies.

Returns: Extended list of connector names that can be used.

vendor_fabric._optional.require_connector(connector: str) None

Ensure a connector’s dependencies are available.

Args: connector: Connector name

Raises: ImportError: With helpful message if dependencies missing