Skip to content

Commit c5a8fe1

Browse files
committed
Removed deprecated functions.
1 parent aee636f commit c5a8fe1

File tree

4 files changed

+47
-84
lines changed

4 files changed

+47
-84
lines changed

domdf_python_tools/paths.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"""
55
Functions for paths and files.
66
7-
.. versionchanged:: 0.8.0
7+
.. versionchanged:: 1.0.0
88
9-
``relpath2`` is deprecated and will be removed in 1.0.0.
9+
Removed ``relpath2``.
1010
Use :func:`domdf_python_tools.paths.relpath` instead.
1111
"""
1212
#
@@ -239,9 +239,6 @@ def relpath(path: PathLike, relative_to: Optional[PathLike] = None) -> pathlib.P
239239
return abs_path
240240

241241

242-
relpath2 = relpath
243-
244-
245242
def write(var: str, filename: PathLike, **kwargs) -> None:
246243
"""
247244
Write a variable to file in the current directory.
@@ -526,8 +523,7 @@ def open( # type: ignore # noqa A003
526523
else:
527524
newline = "\n"
528525

529-
return super(
530-
).open( # type: ignore
526+
return super().open( # type: ignore
531527
mode,
532528
buffering=buffering,
533529
encoding=encoding,

domdf_python_tools/stringlist.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
"""
55
A list of strings that represent lines in a multiline string.
66
7-
.. versionchanged:: 0.8.0
7+
.. versionchanged:: 1.0.0
88
9-
String moved to :mod:`domdf_python_tools.typing`.
10-
It will be removed from this module in 1.0.0
9+
``String`` should now be imported from :mod:`domdf_python_tools.typing`.
1110
"""
1211
#
1312
# Copyright © 2020 Dominic Davis-Foster <[email protected]>
@@ -36,8 +35,6 @@
3635
from domdf_python_tools.typing import String
3736
from domdf_python_tools.utils import convert_indents
3837

39-
String = String
40-
4138
__all__ = ["Indent", "StringList"]
4239

4340

domdf_python_tools/utils.py

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
"""
66
General utility functions.
77
8-
.. versionchanged:: 0.8.0
9-
10-
``tuple2str`` and ``list2string`` are deprecated and will be removed in 1.0.0.
11-
Use :func:`domdf_python_tools.utils.list2str` instead.
8+
.. versionchanged:: 1.0.0
9+
10+
* Removed ``tuple2str`` and ``list2string``.
11+
Use :func:`domdf_python_tools.utils.list2str` instead.
12+
* Removed ``as_text`` and ``word_join``.
13+
Import from :mod:`domdf_python_tools.words` instead.
14+
* Removed ``splitLen``.
15+
Use :func:`domdf_python_tools.utils.split_len` instead.
1216
"""
1317
#
1418
# Copyright © 2018-2020 Dominic Davis-Foster <[email protected]>
@@ -723,54 +727,3 @@ def _inner(*args, **kwargs):
723727
return _inner
724728

725729
return _function_wrapper
726-
727-
728-
# Moved elsewhere
729-
as_text = deprecated(
730-
deprecated_in="0.8.0",
731-
removed_in="1.0.0",
732-
current_version=__version__,
733-
details="Import from 'domdf_python_tools.words' instead.",
734-
)(
735-
domdf_python_tools.words.as_text
736-
)
737-
738-
word_join = deprecated(
739-
deprecated_in="0.8.0",
740-
removed_in="1.0.0",
741-
current_version=__version__,
742-
details="Import from 'domdf_python_tools.words' instead.",
743-
)(
744-
domdf_python_tools.words.word_join
745-
)
746-
747-
# Deprecated aliases
748-
tuple2str = deprecated(
749-
deprecated_in="0.8.0",
750-
removed_in="1.0.0",
751-
current_version=__version__,
752-
details="Use 'domdf_python_tools.utils.list2str' instead.",
753-
name="tuple2str",
754-
)(
755-
list2str
756-
)
757-
758-
list2string = deprecated(
759-
deprecated_in="0.8.0",
760-
removed_in="1.0.0",
761-
current_version=__version__,
762-
details="Use 'domdf_python_tools.utils.list2str' instead.",
763-
name="list2string",
764-
)(
765-
list2str
766-
)
767-
768-
splitLen = deprecated(
769-
deprecated_in="0.8.0",
770-
removed_in="1.0.0",
771-
current_version=__version__,
772-
details="Use 'domdf_python_tools.utils.split_len' instead.",
773-
name="splitLen",
774-
)(
775-
split_len
776-
)

tests/test_utils.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from domdf_python_tools.paths import PathPlus
2525
from domdf_python_tools.testing import testing_boolean_values
2626
from domdf_python_tools.typing import HasHead
27-
from domdf_python_tools.utils import coloured_diff, head
27+
from domdf_python_tools.utils import coloured_diff, deprecated, head
2828

2929

3030
def test_pyversion():
@@ -485,30 +485,47 @@ def test_str(self):
485485
assert head("Hello World", 5) == "Hello..."
486486

487487

488-
def test_deprecations():
489-
# this package
490-
from domdf_python_tools.utils import as_text, list2string, tuple2str, word_join
488+
def test_deprecation():
489+
490+
def func(*args, **kwargs):
491+
"""
492+
A normal function.
493+
"""
494+
495+
return args, kwargs
496+
497+
@deprecated(deprecated_in="1", removed_in="3", current_version="2", details="use 'bar' instead.")
498+
def deprecated_func(*args, **kwargs):
499+
"""
500+
A deprecated function.
501+
"""
502+
503+
return args, kwargs
504+
505+
deprecated_alias = deprecated(
506+
deprecated_in="1",
507+
removed_in="3",
508+
current_version="2",
509+
details="use 'bar' instead.",
510+
name="deprecated_alias",
511+
)(func)
491512

492513
with pytest.warns(DeprecationWarning) as record:
493-
as_text(1)
494-
word_join(["a", "b"])
495-
tuple2str(("a", "b"))
496-
list2string(["a", "b"])
514+
assert deprecated_func(1, a_list=["a", "b"]) == ((1, ), {"a_list": ["a", "b"]})
515+
assert deprecated_alias(1, a_list=["a", "b"]) == ((1, ), {"a_list": ["a", "b"]})
497516

498-
assert len(record) == 4
517+
assert len(record) == 2
499518
assert record[0].message.args == ( # type: ignore
500-
'as_text', '0.8.0', '1.0.0', "Import from 'domdf_python_tools.words' instead."
519+
'deprecated_func', '1', '3', "use 'bar' instead."
501520
)
502521
assert record[1].message.args == ( # type: ignore
503-
'word_join', '0.8.0', '1.0.0', "Import from 'domdf_python_tools.words' instead."
504-
)
505-
assert record[2].message.args == ( # type: ignore
506-
'tuple2str', '0.8.0', '1.0.0', "Use 'domdf_python_tools.utils.list2str' instead."
507-
)
508-
assert record[3].message.args == ( # type: ignore
509-
'list2string', '0.8.0', '1.0.0', "Use 'domdf_python_tools.utils.list2str' instead."
522+
'deprecated_alias', '1', '3', "use 'bar' instead."
510523
)
511524

525+
assert ".. deprecated::" in deprecated_func.__doc__
526+
assert ".. deprecated::" in deprecated_alias.__doc__
527+
assert ".. deprecated::" not in func.__doc__
528+
512529

513530
def test_diff(file_regression: FileRegressionFixture):
514531
data_dir = PathPlus(__file__).parent / "test_diff"

0 commit comments

Comments
 (0)