From b7beb18da0811fed6c88430c854c4ddaeaea73cc Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Tue, 19 Sep 2023 23:52:51 +0200 Subject: [PATCH] Convert DeprecationWarnings to Futurewarnings for deprecated decorators. --- docs/source/changes.md | 2 ++ src/_pytask/mark/__init__.pyi | 6 +++--- src/_pytask/mark/structures.py | 4 ++-- tests/test_mark.py | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/source/changes.md b/docs/source/changes.md index 47dbd86cc..4ecf7d825 100644 --- a/docs/source/changes.md +++ b/docs/source/changes.md @@ -36,6 +36,8 @@ releases are available on [PyPI](https://pypi.org/project/pytask) and - {pull}`416` removes `.from_annot` again. - {pull}`417` deprecates {func}`pytask.mark.task` in favor of {func}`pytask.task`. - {pull}`418` fixes and error and simplifies code in `dag.py`. +- {pull}`420` converts `DeprecationWarning`s to `FutureWarning`s for the deprecated + decorators. ## 0.3.2 - 2023-06-07 diff --git a/src/_pytask/mark/__init__.pyi b/src/_pytask/mark/__init__.pyi index 2894e6bfe..9d488948c 100644 --- a/src/_pytask/mark/__init__.pyi +++ b/src/_pytask/mark/__init__.pyi @@ -17,21 +17,21 @@ def select_by_mark(session: Session, dag: nx.DiGraph) -> set[str]: ... class MARK_GEN: # noqa: N801 @deprecated( "'@pytask.mark.produces' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. To upgrade your project to the new syntax, read the tutorial on product and dependencies: https://tinyurl.com/yrezszr4.", # noqa: E501, PYI053 - category=DeprecationWarning, + category=FutureWarning, stacklevel=1, ) @staticmethod def produces(objects: PyTree[str | Path]) -> None: ... @deprecated( "'@pytask.mark.depends_on' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. To upgrade your project to the new syntax, read the tutorial on product and dependencies: https://tinyurl.com/yrezszr4.", # noqa: E501, PYI053 - category=DeprecationWarning, + category=FutureWarning, stacklevel=1, ) @staticmethod def depends_on(objects: PyTree[str | Path]) -> None: ... @deprecated( "'@pytask.mark.task' is deprecated starting pytask v0.4.0 and will be removed in v0.5.0. Use '@pytask.task' instead.", # noqa: E501, PYI053 - category=DeprecationWarning, + category=FutureWarning, stacklevel=1, ) @staticmethod diff --git a/src/_pytask/mark/structures.py b/src/_pytask/mark/structures.py index 1531e3ea9..8a2415e18 100644 --- a/src/_pytask/mark/structures.py +++ b/src/_pytask/mark/structures.py @@ -202,7 +202,7 @@ def __getattr__(self, name: str) -> MarkDecorator | Any: if name in ("depends_on", "produces"): warnings.warn( _DEPRECATION_DECORATOR.format(name), - category=DeprecationWarning, + category=FutureWarning, stacklevel=1, ) @@ -233,7 +233,7 @@ def __getattr__(self, name: str) -> MarkDecorator | Any: warnings.warn( "'@pytask.mark.task' is deprecated starting pytask v0.4.0 and will be " "removed in v0.5.0. Use '@pytask.task' instead.", - category=DeprecationWarning, + category=FutureWarning, stacklevel=1, ) diff --git a/tests/test_mark.py b/tests/test_mark.py index cd2355eda..101664f7f 100644 --- a/tests/test_mark.py +++ b/tests/test_mark.py @@ -375,8 +375,8 @@ def task_write_text(depends_on, produces): capture_output=True, check=False, ) - assert b"DeprecationWarning: '@pytask.mark.depends_on'" in result.stdout - assert b"DeprecationWarning: '@pytask.mark.produces'" in result.stdout + assert b"FutureWarning: '@pytask.mark.depends_on'" in result.stdout + assert b"FutureWarning: '@pytask.mark.produces'" in result.stdout @pytest.mark.end_to_end() @@ -394,4 +394,4 @@ def task_write_text(): ... capture_output=True, check=False, ) - assert b"DeprecationWarning: '@pytask.mark.task'" in result.stdout + assert b"FutureWarning: '@pytask.mark.task'" in result.stdout