enum_tools.utils

General utility functions.

Classes:

HasMRO

typing.Protocol for classes that have a method resolution order magic method (__mro__).

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: Protocol

typing.Protocol for classes that have a method resolution order magic method (__mro__).

This protocol is runtime checkable.

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

__mro__ = (<class 'enum_tools.utils.HasMRO'>, <class 'typing_extensions.Protocol'>, <class 'typing.Generic'>, <class 'object'>)

Type:    tuple

__non_callable_proto_members__ = {'__mro__'}

Type:    set

get_base_object(enum)[source]

Returns the object type of the enum’s members.

If the members are of indeterminate type then the object class is returned.

Parameters

enum (Type[HasMRO])

Return type

Type

Raises

TypeError – If enum is not an Enum.

is_enum(obj)[source]

Returns True if obj is an enum.Enum.

Parameters

obj (Type)

Return type

bool

is_enum_member(obj)[source]

Returns True if obj is an enum.Enum member.

Parameters

obj (Type)

Return type

bool

is_flag(obj)[source]

Returns True if obj is an enum.Flag.

Parameters

obj (Type)

Return type

bool