summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth M Morton <seth.m.morton@gmail.com>2018-11-18 18:34:24 -0800
committerSeth M Morton <seth.m.morton@gmail.com>2018-11-18 20:25:23 -0800
commite0fa14bdf38e8c6b4d6d9ebea4c59fdac8a6a906 (patch)
tree8861fa2f4e978cbd4ff68d33ee03114d1171ecc9
parent48cc9819a93aad94b10d0ff9087a2d63f0623fc2 (diff)
downloadnatsort-e0fa14bdf38e8c6b4d6d9ebea4c59fdac8a6a906.tar.gz
Remove versorted, index_versorted, ns.V, and ns.VERSION
Good riddance to bad rubbish. The existence of these functions is at best misleading.
-rw-r--r--natsort/__init__.py12
-rw-r--r--natsort/natsort.py39
-rw-r--r--natsort/ns_enum.py18
-rw-r--r--tests/test_natsorted_convenience.py14
-rw-r--r--tests/test_utils.py6
5 files changed, 1 insertions, 88 deletions
diff --git a/natsort/__init__.py b/natsort/__init__.py
index 787da5f..7a215d7 100644
--- a/natsort/__init__.py
+++ b/natsort/__init__.py
@@ -2,7 +2,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
-import warnings
from natsort.natsort import (
as_ascii,
@@ -12,14 +11,12 @@ from natsort.natsort import (
index_humansorted,
index_natsorted,
index_realsorted,
- index_versorted,
natsort_key,
natsort_keygen,
natsorted,
ns,
order_by_index,
realsorted,
- versorted,
)
from natsort.utils import chain_functions
@@ -32,11 +29,9 @@ __all__ = [
"natsort_key",
"natsort_keygen",
"natsorted",
- "versorted",
"humansorted",
"realsorted",
"index_natsorted",
- "index_versorted",
"index_humansorted",
"index_realsorted",
"order_by_index",
@@ -49,9 +44,4 @@ __all__ = [
]
# Add the ns keys to this namespace for convenience.
-# A dict comprehension is not used for Python 2.6 compatibility.
-# We catch warnings from the deprecated ns enum values when adding
-# them to natsort's main namespace.
-with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- globals().update(ns._asdict())
+globals().update(ns._asdict())
diff --git a/natsort/natsort.py b/natsort/natsort.py
index ff4fa17..4ab4060 100644
--- a/natsort/natsort.py
+++ b/natsort/natsort.py
@@ -10,7 +10,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
import sys
from functools import partial
from operator import itemgetter
-from warnings import warn
import natsort.compat.locale
from natsort import utils
@@ -269,25 +268,6 @@ def natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
@u_format
-def versorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
- """
- Identical to :func:`natsorted`.
-
- This function is deprecated as of :mod:`natsort` 5.5.0, and will be
- removed in 6.0.0.
-
- See Also
- --------
- natsorted
-
- """
- msg = "versorted is deprecated as of 5.5.0 and will be removed in 6.0.0, "
- msg += "please use natsorted instead."
- warn(msg, DeprecationWarning, stacklevel=2)
- return natsorted(seq, key, reverse, alg)
-
-
-@u_format
def humansorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
"""
Convenience function to properly sort non-numeric characters.
@@ -465,25 +445,6 @@ def index_natsorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
@u_format
-def index_versorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
- """
- Identical to :func:`index_natsorted`.
-
- This function is deprecated as of :mod:`natsort` 5.5.0, and will be
- removed in 6.0.0.
-
- See Also
- --------
- index_natsorted
-
- """
- msg = "index_versorted is deprecated as of 5.5.0 and will be removed in 6.0.0, "
- msg += "please use index_natsorted instead."
- warn(msg, DeprecationWarning, stacklevel=2)
- return index_natsorted(seq, key, reverse, alg)
-
-
-@u_format
def index_humansorted(seq, key=None, reverse=False, alg=ns.DEFAULT):
"""
This is a wrapper around ``index_natsorted(seq, alg=ns.LOCALE)``.
diff --git a/natsort/ns_enum.py b/natsort/ns_enum.py
index 8605574..91f7f71 100644
--- a/natsort/ns_enum.py
+++ b/natsort/ns_enum.py
@@ -6,7 +6,6 @@ what algorithm natsort uses.
from __future__ import absolute_import, division, print_function, unicode_literals
import collections
-import warnings
# The below are the base ns options. The values will be stored as powers
# of two so bitmasks can be used to extract the user's requested options.
@@ -175,10 +174,6 @@ class _NSEnum(collections.namedtuple("_NSEnum", enum_fields.keys())):
If an NaN shows up in the input, this instructs `natsort` to
treat these as +Infinity and place them after all the other numbers.
By default, an NaN be treated as -Infinity and be placed first.
- VERSION, V
- Deprecated as of `natsort` version 5.0.0; this option is now
- a no-op because it is the default. It will be removed in `natsort`
- version 6.0.0.
Notes
-----
@@ -193,19 +188,6 @@ class _NSEnum(collections.namedtuple("_NSEnum", enum_fields.keys())):
"""
- _msg = "ns.{0} is deprecated and will be removed in natsort 6.0.0, "
- _msg += "this option does nothing so please simply remove its use."
-
- @property
- def V(self): # noqa: N802
- warnings.warn(self._msg.format("V"), DeprecationWarning, stacklevel=2)
- return 0
-
- @property
- def VERSION(self): # noqa: N802
- warnings.warn(self._msg.format("VERSION"), DeprecationWarning, stacklevel=2)
- return 0
-
# Here is where the instance of the ns enum that will be exported is created.
# It is a poor-man's singleton.
diff --git a/tests/test_natsorted_convenience.py b/tests/test_natsorted_convenience.py
index 3c26be0..876a4e7 100644
--- a/tests/test_natsorted_convenience.py
+++ b/tests/test_natsorted_convenience.py
@@ -16,12 +16,10 @@ from natsort import (
index_humansorted,
index_natsorted,
index_realsorted,
- index_versorted,
natsorted,
ns,
order_by_index,
realsorted,
- versorted,
)
from natsort.compat.py23 import PY_VERSION
@@ -66,12 +64,6 @@ def test_as_utf8_converts_bytes_to_utf8():
assert decoder("utf8")(b"bytes") == as_utf8(b"bytes")
-def test_versorted_is_identical_to_natsorted(version_list):
- # versorted is retained for backwards compatibility
- with pytest.warns(DeprecationWarning, match="use natsorted instead"):
- assert versorted(version_list) == natsorted(version_list)
-
-
def test_realsorted_is_identical_to_natsorted_with_real_alg(float_list):
assert realsorted(float_list) == natsorted(float_list, alg=ns.REAL)
@@ -101,12 +93,6 @@ def test_index_natsorted_applies_key_function_before_sorting():
assert index_natsorted(given, key=itemgetter(1)) == expected
-def test_index_versorted_is_identical_to_index_natsorted(version_list):
- # index_versorted is retained for backwards compatibility
- with pytest.warns(DeprecationWarning, match="use index_natsorted instead"):
- assert index_versorted(version_list) == index_natsorted(version_list)
-
-
def test_index_realsorted_is_identical_to_index_natsorted_with_real_alg(float_list):
assert index_realsorted(float_list) == index_natsorted(float_list, alg=ns.REAL)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index ec0f729..5cd469a 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -73,12 +73,6 @@ def test_ns_enum_values_and_aliases(alg, value_or_alias):
assert alg == value_or_alias
-@pytest.mark.parametrize("alg", ["V", "VERSION"])
-def test_deprecated_ns_enum_values_and_aliases_produce_warning(alg):
- with pytest.warns(DeprecationWarning, match="please simply remove"):
- assert getattr(ns, alg) == 0
-
-
def test_chain_functions_is_a_no_op_if_no_functions_are_given():
x = 2345
assert utils.chain_functions([])(x) is x