bridge.utils.instantiate_utils#

Module Contents#

Functions#

_as_module_prefix

Ensure prefix ends with ‘.’ so allowlist matches at module boundaries.

_seed_allowlist

register_allowed_target_prefix

Register an additional allowed module prefix for target instantiation.

_validate_target_prefix

Validate that a target string is permitted by Bridge hardening rules.

_resolve_target

Resolve target string, type, or callable after Bridge validation.

Data#

API#

bridge.utils.instantiate_utils._ALLOWED_TARGET_PREFIXES: set[str]#

None

bridge.utils.instantiate_utils._TARGET_ALLOWLIST_MUTATORS: tuple[str, ...]#

(‘add_prefix’, ‘remove_prefix’, ‘add_exact’, ‘remove_exact’, ‘disable’, ‘enable’)

bridge.utils.instantiate_utils._ALLOWED_PRIVATE_TARGETS: set[str]#

None

bridge.utils.instantiate_utils._DISALLOWED_TARGETS: set[str]#

None

bridge.utils.instantiate_utils._DISALLOWED_CALLABLE_FIELD_NAMES: set[str]#

None

bridge.utils.instantiate_utils._as_module_prefix(prefix: str) str#

Ensure prefix ends with ‘.’ so allowlist matches at module boundaries.

bridge.utils.instantiate_utils._seed_allowlist() None#
bridge.utils.instantiate_utils.register_allowed_target_prefix(prefix: str) None#

Register an additional allowed module prefix for target instantiation.

This allows extending the default allowlist for use cases that require instantiating classes from other packages.

bridge.utils.instantiate_utils._validate_target_prefix(*, target: str, full_key: str | int) None#

Validate that a target string is permitted by Bridge hardening rules.

bridge.utils.instantiate_utils._resolve_target(
target: str | type | Callable[..., Any],
full_key: str | int,
check_callable: bool = True,
) type | Callable[..., Any] | object#

Resolve target string, type, or callable after Bridge validation.