Skip to content

Commit

Permalink
Optional name when registering enum class
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaughn Kottler authored and Vaughn Kottler committed Feb 10, 2023
1 parent d3dc372 commit 0fb1868
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion runtimepy/enum/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ def runtime_enum(cls, identifier: int) -> _RuntimeEnum:
return _RuntimeEnum.from_enum(cls, identifier)

@classmethod
def register_enum(cls, name: str, registry: EnumRegistry) -> _RuntimeEnum:
def register_enum(
cls, registry: EnumRegistry, name: str = None
) -> _RuntimeEnum:
"""Register an enumeration to a registry."""

if name is None:
name = cls.__name__

result = registry.register_dict(name, _RuntimeEnum.data_from_enum(cls))
assert result is not None
return result

0 comments on commit 0fb1868

Please sign in to comment.