diff options
author | Seth Morton <seth.m.morton@gmail.com> | 2022-09-01 13:51:27 -0700 |
---|---|---|
committer | Seth Morton <seth.m.morton@gmail.com> | 2022-09-01 13:59:30 -0700 |
commit | c634a4a8437de989b4394c48cd80e19ea82040f8 (patch) | |
tree | 758b831ad72636471e0630f38b676b86683f39e9 /natsort | |
parent | 22cdc562baf60389a5f64a0ce241caf34d09abea (diff) | |
download | natsort-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.py | 11 |
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 |