diff options
Diffstat (limited to 'natsort')
-rw-r--r-- | natsort/compat/fake_fastnumbers.py | 6 | ||||
-rw-r--r-- | natsort/compat/locale.py | 8 | ||||
-rw-r--r-- | natsort/natsort.py | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/natsort/compat/fake_fastnumbers.py b/natsort/compat/fake_fastnumbers.py index 7177551..570083f 100644 --- a/natsort/compat/fake_fastnumbers.py +++ b/natsort/compat/fake_fastnumbers.py @@ -10,7 +10,7 @@ import unicodedata # Local imports. from natsort.unicode_numbers import decimal_chars -NAN_INF = [ +_NAN_INF = [ "INF", "INf", "Inf", @@ -28,8 +28,8 @@ NAN_INF = [ "nAN", "Nan", ] -NAN_INF.extend(["+" + x[:2] for x in NAN_INF] + ["-" + x[:2] for x in NAN_INF]) -NAN_INF = frozenset(NAN_INF) +_NAN_INF.extend(["+" + x[:2] for x in _NAN_INF] + ["-" + x[:2] for x in _NAN_INF]) +NAN_INF = frozenset(_NAN_INF) ASCII_NUMS = "0123456789+-" POTENTIAL_FIRST_CHAR = frozenset(decimal_chars + list(ASCII_NUMS + ".")) diff --git a/natsort/compat/locale.py b/natsort/compat/locale.py index ccb5592..1edb67f 100644 --- a/natsort/compat/locale.py +++ b/natsort/compat/locale.py @@ -3,9 +3,8 @@ Interface for natsort to access locale functionality without having to worry about if it is using PyICU or the built-in locale. """ - -# Std. lib imports. import sys +import typing as t # This string should be sorted after any other byte string because # it contains the max unicode character repeated 20 times. @@ -13,6 +12,11 @@ import sys null_string = "" null_string_max = chr(sys.maxunicode) * 20 +# This variable could be str or bytes depending on the locale library +# being used, so give the type-checker this information. +null_string_locale: t.Union[str, bytes] +null_string_locale_max: t.Union[str, bytes] + # strxfrm can be buggy (especially on BSD-based systems), # so prefer icu if available. try: # noqa: C901 diff --git a/natsort/natsort.py b/natsort/natsort.py index 0430a44..1402cf8 100644 --- a/natsort/natsort.py +++ b/natsort/natsort.py @@ -622,7 +622,7 @@ def _split_apply(v, key=None): # Choose the implementation based on the host OS if platform.system() == "Windows": - from ctypes import wintypes, windll + from ctypes import wintypes, windll # type: ignore from functools import cmp_to_key _windows_sort_cmp = windll.Shlwapi.StrCmpLogicalW |