From fac52f3f35cc36a56847109f837631ded95df636 Mon Sep 17 00:00:00 2001 From: Joe Bylund Date: Thu, 25 May 2023 13:29:12 -0400 Subject: [PATCH] Replace deprecated pkg_resources with importlib_metadata (the backport version). --- arango/client.py | 4 ++-- setup.py | 1 + tests/test_client.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arango/client.py b/arango/client.py index 7bdd6f4a..0c0c1892 100644 --- a/arango/client.py +++ b/arango/client.py @@ -3,7 +3,7 @@ from json import dumps, loads from typing import Any, Callable, Optional, Sequence, Union -from pkg_resources import get_distribution +import importlib_metadata from arango.connection import ( BasicConnection, @@ -127,7 +127,7 @@ def version(self) -> str: :return: Client version. :rtype: str """ - version: str = get_distribution("python-arango").version + version: str = importlib_metadata.version("python-arango") return version @property diff --git a/setup.py b/setup.py index 4af47963..8f381e03 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,7 @@ "requests_toolbelt", "PyJWT", "setuptools>=42", + "importlib_metadata>=4.7.1", ], extras_require={ "dev": [ diff --git a/tests/test_client.py b/tests/test_client.py index 1271f752..a73e8ebe 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,8 +1,8 @@ import json from typing import Union +import importlib_metadata import pytest -from pkg_resources import get_distribution from requests import Session from arango.client import ArangoClient @@ -21,7 +21,7 @@ def test_client_attributes(): http_client = DefaultHTTPClient() client = ArangoClient(hosts="http://127.0.0.1:8529", http_client=http_client) - assert client.version == get_distribution("python-arango").version + assert client.version == importlib_metadata.version("python-arango") assert client.hosts == ["http://127.0.0.1:8529"] assert repr(client) == "" @@ -36,7 +36,7 @@ def test_client_attributes(): serializer=json.dumps, deserializer=json.loads, ) - assert client.version == get_distribution("python-arango").version + assert client.version == importlib_metadata.version("python-arango") assert client.hosts == client_hosts assert repr(client) == client_repr assert isinstance(client._host_resolver, RoundRobinHostResolver) @@ -48,7 +48,7 @@ def test_client_attributes(): serializer=json.dumps, deserializer=json.loads, ) - assert client.version == get_distribution("python-arango").version + assert client.version == importlib_metadata.version("python-arango") assert client.hosts == client_hosts assert repr(client) == client_repr assert isinstance(client._host_resolver, RandomHostResolver)