Skip to content

Replace pkg_resources with importlib_metadata #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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