From b1467bcf7d01dfd7b07aca3442310e9f00849cbf Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 13 Jan 2025 13:18:34 +0200 Subject: [PATCH] Be less fancy in `_PluralTuple` --- babel/messages/plurals.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/babel/messages/plurals.py b/babel/messages/plurals.py index cb1ea5b3..1bbd9620 100644 --- a/babel/messages/plurals.py +++ b/babel/messages/plurals.py @@ -9,8 +9,6 @@ """ from __future__ import annotations -from operator import itemgetter - from babel.core import Locale, default_locale # XXX: remove this file, duplication with babel.plural @@ -209,12 +207,21 @@ class _PluralTuple(tuple): """A tuple with plural information.""" __slots__ = () - num_plurals = property(itemgetter(0), doc=""" - The number of plurals used by the locale.""") - plural_expr = property(itemgetter(1), doc=""" - The plural expression used by the locale.""") - plural_forms = property(lambda x: 'nplurals={}; plural={};'.format(*x), doc=""" - The plural expression used by the catalog or locale.""") + + @property + def num_plurals(self) -> int: + """The number of plurals used by the locale.""" + return self[0] + + @property + def plural_expr(self) -> str: + """The plural expression used by the locale.""" + return self[1] + + @property + def plural_forms(self) -> str: + """The plural expression used by the catalog or locale.""" + return f'nplurals={self[0]}; plural={self[1]};' def __str__(self) -> str: return self.plural_forms -- 2.47.2