Skip to content

Commit

Permalink
Replace deprecated pkg_resources with importlib_metadata (the backpor…
Browse files Browse the repository at this point in the history
…t version).
  • Loading branch information
jbylund authored and apetenchea committed Jun 2, 2023
1 parent 8a34aa5 commit 4a45183
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions arango/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"requests_toolbelt",
"PyJWT",
"setuptools>=42",
"importlib_metadata>=4.7.1",
],
extras_require={
"dev": [
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) == "<ArangoClient http://127.0.0.1:8529>"
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 4a45183

Please sign in to comment.