FeatureFlag#

from tmlt.analytics import FeatureFlag
class tmlt.analytics.FeatureFlag(summary, default)#

Bases: object

A flag for enabling an individual feature.

An instance of FeatureFlag can be used as a bool, or raise_if_disabled() can raise an appropriate exception if the corresponding feature is used while the flag is disabled.

__bool__()#

Returns whether the flag is enabled.

Return type:

bool

__str__()#

Returns a describing the state of this feature flag.

Return type:

str

enable()#

Enables the features controlled by this feature flag.

disable()#

Disables the features controlled by this feature flag.

reset()#

Resets this feature flag to its base state.

enabled()#

A context manager inside which this feature flag will be enabled.

When the context manager exits, the feature flag will be reset to the state it was in before entering the context manager, ignoring any changes that occurred inside the context.

disabled()#

A context manager inside which this feature flag will be disabled.

When the context manager exits, the feature flag will be reset to the state it was in before entering the context manager, ignoring any changes that occurred inside the context.

raise_if_disabled()#

Raise a RuntimeError if this feature flag is not enabled.