pg.contextual_override¶
Accessible via pg.contextual_override, pg.utils.contextual_override.
- contextual_override(*, cascade=False, override_attrs=False, **variables)[source]¶
Context manager to provide contextual values under a scope.
Please be aware that contextual value override are per-thread. If you want to propagate the contextual value override to other threads, please obtain a wrapper function for a user function using pg.with_contextual_override(func).
- Return type:
- Parameters:
cascade – If True, this override will apply to both current scope and nested scope, meaning that this pg.contextual_override will take precedence over all nested pg.contextual_override on the overriden variables.
override_attrs – If True, this override will apply to attributes that already have values. Otherwise overridden variables will only be used for contextual attributes whose values are not present.
**variables – Key/values as override for contextual attributes.
- Returns:
A dict of attribute names to their contextual overrides.