summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth Morton <seth.m.morton@gmail.com>2021-10-23 21:56:50 -0700
committerGitHub <noreply@github.com>2021-10-23 21:56:50 -0700
commit43b70f4f35e5575662df75922bd316fa7957e289 (patch)
treefad3d284302f200ea712b51e8b2140bec3ae5a4c
parentafe12261977a219bef0d0c0e6a40e1f81cf44d4f (diff)
parent36f0d6f553c02c5937af94541463d30656537615 (diff)
downloadnatsort-43b70f4f35e5575662df75922bd316fa7957e289.tar.gz
Merge pull request #135 from thethiny/master
Support Type Hinting
-rw-r--r--natsort/natsort.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/natsort/natsort.py b/natsort/natsort.py
index 8e3a7b5..0430a44 100644
--- a/natsort/natsort.py
+++ b/natsort/natsort.py
@@ -9,11 +9,16 @@ The majority of the "work" is defined in utils.py.
import platform
from functools import partial
from operator import itemgetter
+from typing import Callable, Iterable, TypeVar
+
+from _typeshed import SupportsLessThan
import natsort.compat.locale
from natsort import utils
from natsort.ns_enum import NS_DUMB, ns
+_T = TypeVar("_T")
+
def decoder(encoding):
"""
@@ -212,7 +217,7 @@ natsort_keygen
"""
-def natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
+def natsorted(seq: Iterable[_T], key: Callable[[_T], SupportsLessThan]=None, reverse=False, alg=ns.DEFAULT):
"""
Sorts an iterable naturally.