Skip to content

Commit

Permalink
Add warnings.deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Jun 29, 2024
1 parent c6788c8 commit 5f257a0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ repos:
# report-junit
- "junit_xml>=1.9"

- "typing-extensions>=4.4.0; python_version < '3.10'" # TypeAlias introduced in 3.10, Self in 3.11
- "typing-extensions>=4.9.0; python_version < '3.13'"
- "pytest"
- "requre"
# Do not install *types-click* - it's not recommended with Click 8 & newer,
Expand Down Expand Up @@ -90,7 +90,7 @@ repos:
# report-junit
- "junit_xml>=1.9"

- "typing-extensions>=4.4.0; python_version < '3.10'" # TypeAlias introduced in 3.10, Self in 3.11
- "typing-extensions>=4.9.0; python_version < '3.13'"
- "pytest"
- "requre"
# Do not install *types-click* - it's not recommended with Click 8 & newer,
Expand Down
5 changes: 5 additions & 0 deletions docs/code/plugin-introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ standard location under ``tmt/steps`` , from all directories
provided in the ``TMT_PLUGINS`` environment variable and from
``tmt.plugin`` entry point.

.. versionchanged:: 1.35
``warnings.deprecated`` is used to advertise deprecated APIs.
Consider adding a static type checker (e.g. ``mypy``) in your
plugin's CI using the ``main`` branch of ``tmt``.


Inheritance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Releases
======================

We have started to use ``warnings.deprecated`` to advertise upcoming
API deprecations.

tmt-1.34
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies = [ # F39 / PyPI
"requests>=2.25.1", # 2.28.2 / 2.31.0
"ruamel.yaml>=0.16.6", # 0.17.32 / 0.17.32
"urllib3>=1.26.5, <3.0", # 1.26.16 / 2.0.4
"typing-extensions>=4.9.0; python_version < '3.13'",
]

[project.optional-dependencies]
Expand Down Expand Up @@ -113,7 +114,6 @@ platforms = ["linux"]
[tool.hatch.envs.dev]
description = "Development environment"
dependencies = [
"typing-extensions>=4.4.0; python_version < '3.10'", # TypeAlias introduced in 3.10, Self in 3.11
"autopep8",
"ruff",
"mypy",
Expand Down Expand Up @@ -398,6 +398,7 @@ builtins-ignorelist = ["help", "format", "input", "filter", "copyright", "max"]
"typing_extensions.Self".msg = "Use tmt._compat.typing.Self instead."
"pathlib.Path".msg = "Use tmt._compat.pathlib.Path instead."
"pathlib.PosixPath".msg = "Use tmt._compat.pathlib.Path instead."
"warnings.deprecated".msg = "Use tmt._compat.warnings.deprecated instead."

[tool.ruff.lint.isort]
known-first-party = ["tmt"]
Expand Down
12 changes: 12 additions & 0 deletions tmt/_compat/warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations

import sys

if sys.version_info >= (3, 13):
from warnings import deprecated
else:
from typing_extensions import deprecated

__all__ = [
"deprecated",
]

0 comments on commit 5f257a0

Please sign in to comment.