From f865a2f948eb11c776b463bc8f5b0866e92e03ea Mon Sep 17 00:00:00 2001 From: jo Date: Wed, 12 Jul 2023 22:56:24 +0200 Subject: [PATCH] feat: move hcloud.__version__.VERSION to hcloud.__version__ --- docs/conf.py | 6 +++--- hcloud/__init__.py | 1 + hcloud/__version__.py | 10 +++++++++- hcloud/_client.py | 4 ++-- hcloud/_version.py | 1 + tests/unit/test_hcloud.py | 5 +++++ 6 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 hcloud/_version.py diff --git a/docs/conf.py b/docs/conf.py index 8836d22a..8d3dc53b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,7 +3,7 @@ from datetime import datetime sys.path.insert(0, os.path.abspath("..")) -from hcloud.__version__ import VERSION # noqa +import hcloud # noqa # Configuration file for the Sphinx documentation builder. # @@ -17,8 +17,8 @@ author = "Hetzner Cloud GmbH" copyright = f"{datetime.now().year}, {author}" -version = VERSION -release = VERSION +version = hcloud.__version__ +release = hcloud.__version__ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/hcloud/__init__.py b/hcloud/__init__.py index 5beda91d..85eb72ed 100644 --- a/hcloud/__init__.py +++ b/hcloud/__init__.py @@ -1,2 +1,3 @@ from ._client import Client # noqa from ._exceptions import APIException, HCloudException # noqa +from ._version import __version__ # noqa diff --git a/hcloud/__version__.py b/hcloud/__version__.py index 0c992210..4c19a034 100644 --- a/hcloud/__version__.py +++ b/hcloud/__version__.py @@ -1 +1,9 @@ -VERSION = "1.24.0" # x-release-please-version +import warnings + +warnings.warn( + "The 'hcloud.__version__.VERSION' constant is deprecated, please use 'hcloud.__version__' instead.", + DeprecationWarning, + stacklevel=2, +) + +from ._version import __version__ as VERSION # noqa diff --git a/hcloud/_client.py b/hcloud/_client.py index e62624f1..6484b6d9 100644 --- a/hcloud/_client.py +++ b/hcloud/_client.py @@ -3,8 +3,8 @@ import requests -from .__version__ import VERSION from ._exceptions import APIException +from ._version import __version__ from .actions.client import ActionsClient from .certificates.client import CertificatesClient from .datacenters.client import DatacentersClient @@ -27,7 +27,7 @@ class Client: """Base Client for accessing the Hetzner Cloud API""" - _version = VERSION + _version = __version__ _retry_wait_time = 0.5 __user_agent_prefix = "hcloud-python" diff --git a/hcloud/_version.py b/hcloud/_version.py new file mode 100644 index 00000000..4627e024 --- /dev/null +++ b/hcloud/_version.py @@ -0,0 +1 @@ +__version__ = "1.24.0" # x-release-please-version diff --git a/tests/unit/test_hcloud.py b/tests/unit/test_hcloud.py index 87ab50aa..a1eef747 100644 --- a/tests/unit/test_hcloud.py +++ b/tests/unit/test_hcloud.py @@ -4,3 +4,8 @@ def test_deprecated_hcloud_hcloud_module(): with pytest.deprecated_call(): from hcloud.hcloud import Client # noqa + + +def test_deprecated_hcloud_version_constant(): + with pytest.deprecated_call(): + from hcloud.__version__ import VERSION # noqa