Skip to content

Commit 4a45183

Browse files
jbylundapetenchea
authored andcommitted
Replace deprecated pkg_resources with importlib_metadata (the backport version).
1 parent 8a34aa5 commit 4a45183

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

arango/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from json import dumps, loads
44
from typing import Any, Callable, Optional, Sequence, Union
55

6-
from pkg_resources import get_distribution
6+
import importlib_metadata
77

88
from arango.connection import (
99
BasicConnection,
@@ -127,7 +127,7 @@ def version(self) -> str:
127127
:return: Client version.
128128
:rtype: str
129129
"""
130-
version: str = get_distribution("python-arango").version
130+
version: str = importlib_metadata.version("python-arango")
131131
return version
132132

133133
@property

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"requests_toolbelt",
2424
"PyJWT",
2525
"setuptools>=42",
26+
"importlib_metadata>=4.7.1",
2627
],
2728
extras_require={
2829
"dev": [

tests/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
22
from typing import Union
33

4+
import importlib_metadata
45
import pytest
5-
from pkg_resources import get_distribution
66
from requests import Session
77

88
from arango.client import ArangoClient
@@ -21,7 +21,7 @@ def test_client_attributes():
2121
http_client = DefaultHTTPClient()
2222

2323
client = ArangoClient(hosts="http://127.0.0.1:8529", http_client=http_client)
24-
assert client.version == get_distribution("python-arango").version
24+
assert client.version == importlib_metadata.version("python-arango")
2525
assert client.hosts == ["http://127.0.0.1:8529"]
2626

2727
assert repr(client) == "<ArangoClient http://127.0.0.1:8529>"
@@ -36,7 +36,7 @@ def test_client_attributes():
3636
serializer=json.dumps,
3737
deserializer=json.loads,
3838
)
39-
assert client.version == get_distribution("python-arango").version
39+
assert client.version == importlib_metadata.version("python-arango")
4040
assert client.hosts == client_hosts
4141
assert repr(client) == client_repr
4242
assert isinstance(client._host_resolver, RoundRobinHostResolver)
@@ -48,7 +48,7 @@ def test_client_attributes():
4848
serializer=json.dumps,
4949
deserializer=json.loads,
5050
)
51-
assert client.version == get_distribution("python-arango").version
51+
assert client.version == importlib_metadata.version("python-arango")
5252
assert client.hosts == client_hosts
5353
assert repr(client) == client_repr
5454
assert isinstance(client._host_resolver, RandomHostResolver)

0 commit comments

Comments
 (0)