backend/pitch_deck_generator/utils/choices.py

10 lines
289 B
Python
Raw Normal View History

2023-08-26 01:17:47 +03:00
from collections.abc import Iterable
from django.db.models.enums import ChoicesMeta
def count_max_length(choices: Iterable | ChoicesMeta):
if isinstance(choices, ChoicesMeta):
return max([len(val) for val in choices.values])
return max([len(val) for val, _ in choices])