summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSeth Morton <seth.m.morton@gmail.com>2022-09-01 13:12:30 -0700
committerSeth Morton <seth.m.morton@gmail.com>2022-09-01 13:59:30 -0700
commit22cdc562baf60389a5f64a0ce241caf34d09abea (patch)
treed123aeaabb2e269028c558576d4e8a9aa126ed3f /tests
parente5d2e4507728e53d1867ac87e169fca1d251d8cf (diff)
downloadnatsort-22cdc562baf60389a5f64a0ce241caf34d09abea.tar.gz
Simplify type hints for public functions
...and to some degree private as well. Previously, the declared hints for natsort were too restrictive. Generics and protocols are now utilized to make the type hints more "open" which is more realistic, since more than just basic types can be sorted.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_os_sorted.py3
-rw-r--r--tests/test_parse_number_function.py4
2 files changed, 3 insertions, 4 deletions
diff --git a/tests/test_os_sorted.py b/tests/test_os_sorted.py
index d0ecc79..f714437 100644
--- a/tests/test_os_sorted.py
+++ b/tests/test_os_sorted.py
@@ -3,7 +3,6 @@
Testing for the OS sorting
"""
import platform
-from typing import cast
import natsort
import pytest
@@ -44,7 +43,7 @@ def test_os_sorted_misc_no_fail() -> None:
def test_os_sorted_key() -> None:
given = ["foo0", "foo2", "goo1"]
expected = ["foo0", "goo1", "foo2"]
- result = natsort.os_sorted(given, key=lambda x: cast(str, x).replace("g", "f"))
+ result = natsort.os_sorted(given, key=lambda x: x.replace("g", "f"))
assert result == expected
diff --git a/tests/test_parse_number_function.py b/tests/test_parse_number_function.py
index e5f417d..85d6b96 100644
--- a/tests/test_parse_number_function.py
+++ b/tests/test_parse_number_function.py
@@ -7,7 +7,7 @@ import pytest
from hypothesis import given
from hypothesis.strategies import floats, integers
from natsort.ns_enum import NSType, ns
-from natsort.utils import MaybeNumTransformer, parse_number_or_none_factory
+from natsort.utils import NumTransformer, parse_number_or_none_factory
@pytest.mark.usefixtures("with_locale_en_us")
@@ -22,7 +22,7 @@ from natsort.utils import MaybeNumTransformer, parse_number_or_none_factory
)
@given(x=floats(allow_nan=False) | integers())
def test_parse_number_factory_makes_function_that_returns_tuple(
- x: Union[float, int], alg: NSType, example_func: MaybeNumTransformer
+ x: Union[float, int], alg: NSType, example_func: NumTransformer
) -> None:
parse_number_func = parse_number_or_none_factory(alg, "", "xx")
assert parse_number_func(x) == example_func(x)