summaryrefslogtreecommitdiff
path: root/natsort
diff options
context:
space:
mode:
authorSeth Morton <seth.m.morton@gmail.com>2022-09-01 13:51:27 -0700
committerSeth Morton <seth.m.morton@gmail.com>2022-09-01 13:59:30 -0700
commitc634a4a8437de989b4394c48cd80e19ea82040f8 (patch)
tree758b831ad72636471e0630f38b676b86683f39e9 /natsort
parent22cdc562baf60389a5f64a0ce241caf34d09abea (diff)
downloadnatsort-c634a4a8437de989b4394c48cd80e19ea82040f8.tar.gz
Add stubs for icu
This way we don't need to use casts in-code.
Diffstat (limited to 'natsort')
-rw-r--r--natsort/compat/locale.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/natsort/compat/locale.py b/natsort/compat/locale.py
index 53080c3..8d7ae48 100644
--- a/natsort/compat/locale.py
+++ b/natsort/compat/locale.py
@@ -40,19 +40,20 @@ try: # noqa: C901
def get_icu_locale() -> str:
language_code, encoding = getlocale()
if language_code is None or encoding is None: # pragma: no cover
- return cast(str, icu.Locale())
- return cast(str, icu.Locale(f"{language_code}.{encoding}"))
+ return icu.Locale()
+ return icu.Locale(f"{language_code}.{encoding}")
def get_strxfrm() -> TrxfmFunc:
- return cast(TrxfmFunc, icu.Collator.createInstance(get_icu_locale()).getSortKey)
+ return icu.Collator.createInstance(get_icu_locale()).getSortKey
def get_thousands_sep() -> str:
sep = icu.DecimalFormatSymbols.kGroupingSeparatorSymbol
- return cast(str, icu.DecimalFormatSymbols(get_icu_locale()).getSymbol(sep))
+ return icu.DecimalFormatSymbols(get_icu_locale()).getSymbol(sep)
def get_decimal_point() -> str:
sep = icu.DecimalFormatSymbols.kDecimalSeparatorSymbol
- return cast(str, icu.DecimalFormatSymbols(get_icu_locale()).getSymbol(sep))
+ return icu.DecimalFormatSymbols(get_icu_locale()).getSymbol(sep)
+
except ImportError:
import locale