enum_tools.utils

General utility functions.

Classes:

HasMRO

typing.Protocol for classes that have a Method Resolution Order magic method.

Functions:

get_base_object(enum)

Returns the object type of the enum’s members.

is_enum(obj)

Returns True if obj is an enum.Enum.

is_enum_member(obj)

Returns True if obj is an enum.Enum member.

is_flag(obj)

Returns True if obj is an enum.Flag.

protocol HasMRO[source]

Bases: typing.Protocol

typing.Protocol for classes that have a Method Resolution Order magic method.

This protocol is runtime checkable.

Classes that implement this protocol must have the following methods / attributes:

__mro__ = (<class 'enum_tools.utils.HasMRO'>, <class 'typing.Protocol'>, <class 'typing.Generic'>, <class 'object'>)
get_base_object(enum)[source]

Returns the object type of the enum’s members.

If the members are of indeterminate type object is returned.

Return type

Type

is_enum(obj)[source]

Returns True if obj is an enum.Enum.

Return type

bool

is_enum_member(obj)[source]

Returns True if obj is an enum.Enum member.

Return type

bool

is_flag(obj)[source]

Returns True if obj is an enum.Flag.

Return type

bool