Skip to content

Commit

Permalink
Remove usage of pkg_resources (deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayalash committed Nov 10, 2023
1 parent a78553d commit cb43bb5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions backslash/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pkg_resources
from ._compat import get_distribution

__version__ = pkg_resources.get_distribution('backslash').version

__version__ = get_distribution("backslash").version
12 changes: 12 additions & 0 deletions backslash/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys

if sys.version_info < (3, 8):
# pylint: disable=unused-import
import pkg_resources

get_distribution = pkg_resources.get_distribution
else:
# pylint: disable=unused-import
import importlib.metadata

get_distribution = importlib.metadata.distribution
4 changes: 2 additions & 2 deletions backslash/contrib/slash_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import itertools
import json
import os
import pkg_resources
import socket
import sys
import time
Expand All @@ -28,6 +27,7 @@
from urlobject import URLObject as URL
from requests import HTTPError
from shlex import quote as shellquote
from packaging.version import parse as parse_version
from ..client import Backslash as BackslashClient
from ..exceptions import ParamsTooLarge
from ..utils import ensure_dir
Expand Down Expand Up @@ -327,7 +327,7 @@ def get_tests_to_resume(self, session_id, filters_dict):

def _get_test_info(self, test):
if test.__slash__.is_interactive() and \
pkg_resources.parse_version(slash.__version__) < pkg_resources.parse_version('1.6.0'):
parse_version(slash.__version__) < parse_version('1.6.0'):
returned = {
'file_name': '<interactive>',
'class_name': '<interactive>',
Expand Down

0 comments on commit cb43bb5

Please sign in to comment.