Skip to content

Commit

Permalink
feat: move hcloud.__version__.VERSION to hcloud.__version__
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Jul 14, 2023
1 parent 413472d commit 5bf68af
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions hcloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from ._client import Client # noqa
from ._exceptions import APIException, HCloudException # noqa
from ._version import __version__ # noqa
10 changes: 9 additions & 1 deletion hcloud/__version__.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions hcloud/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down
1 change: 1 addition & 0 deletions hcloud/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.24.0" # x-release-please-version
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
readme = readme_file.read()

version = {}
with open("hcloud/__version__.py") as fp:
with open("hcloud/_version.py") as fp:
exec(fp.read(), version)

setup(
name="hcloud",
version=version["VERSION"],
version=version["__version__"],
keywords="hcloud hetzner cloud",
description="Official Hetzner Cloud python library",
long_description=readme,
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_hcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5bf68af

Please sign in to comment.