Skip to content

Commit e8c8ad0

Browse files
committed
_get_dist backward compatible with 3.6
1 parent 27e66b7 commit e8c8ad0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

proxy/common/_version.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,24 @@
1313
from typing import Tuple, Union
1414

1515

16+
def _get_dist(distribution_name: str) -> str:
17+
try:
18+
# pylint: disable=import-outside-toplevel
19+
from importlib.metadata import version # noqa: WPS433
20+
21+
return version(distribution_name)
22+
except ModuleNotFoundError: # pragma: no cover
23+
# pylint: disable=import-outside-toplevel
24+
from pkg_resources import get_distribution # noqa: WPS433
25+
26+
return get_distribution(distribution_name).version
27+
28+
1629
try:
1730
# pylint: disable=unused-import
1831
from ._scm_version import version as __version__ # noqa: WPS433, WPS436
1932
from ._scm_version import version_tuple as _ver_tup # noqa: WPS433, WPS436
20-
except ImportError: # pragma: no cover
21-
from importlib.metadata import version as _get_dist # noqa: WPS433
22-
33+
except ImportError: # pragma: no cover
2334
__version__ = _get_dist('proxy.py') # noqa: WPS440
2435

2536

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ deps =
262262
pre-commit
263263
pylint >= 2.5.3
264264
pylint-pytest < 1.1.0
265-
pytest-mock >= 3.6.1
265+
pytest-mock == 3.6.1
266266
-r docs/requirements.in
267267
-r requirements-tunnel.txt
268268
-r requirements-testing.txt

0 commit comments

Comments
 (0)