Skip to content

Commit

Permalink
Merge pull request #2037 from berhoel/master
Browse files Browse the repository at this point in the history
Replace pkg_resources.parse_version by packaging.version.Version
  • Loading branch information
gopar authored Jan 9, 2024
2 parents 7ff8ffa + 6a6655e commit 777e990
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
15 changes: 10 additions & 5 deletions elpy/blackutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
from elpy.rpc import Fault
# in case pkg_resources is not properly installed
# (see https://github.com/jorgenschaefer/elpy/issues/1674).
# in case pkg_resources is not properly installed
# (see https://github.com/jorgenschaefer/elpy/issues/1674).
try:
from pkg_resources import parse_version
from packaging.version import Version as parse_version
except ImportError: # pragma: no cover
def parse_version(*arg, **kwargs):
raise Fault("`pkg_resources` could not be imported, "
"please reinstall Elpy RPC virtualenv with"
" `M-x elpy-rpc-reinstall-virtualenv`", code=400)
try:
from pkg_resources import parse_version
except ImportError: # pragma: no cover
def parse_version(*arg, **kwargs):
raise Fault("`pkg_resources` could not be imported, "
"please reinstall Elpy RPC virtualenv with"
" `M-x elpy-rpc-reinstall-virtualenv`", code=400)

import os

Expand Down
13 changes: 8 additions & 5 deletions elpy/jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
# in case pkg_resources is not properly installed
# (see https://github.com/jorgenschaefer/elpy/issues/1674).
try:
from pkg_resources import parse_version
from packaging.version import Version as parse_version
except ImportError: # pragma: no cover
def parse_version(*arg, **kwargs):
raise Fault("`pkg_resources` could not be imported, "
"please reinstall Elpy RPC virtualenv with"
" `M-x elpy-rpc-reinstall-virtualenv`", code=400)
try:
from pkg_resources import parse_version
except ImportError: # pragma: no cover
def parse_version(*arg, **kwargs):
raise Fault("`pkg_resources` could not be imported, "
"please reinstall Elpy RPC virtualenv with"
" `M-x elpy-rpc-reinstall-virtualenv`", code=400)
JEDISUP17 = parse_version(jedi.__version__) >= parse_version("0.17.0")
JEDISUP18 = parse_version(jedi.__version__) >= parse_version("0.18.0")

Expand Down

0 comments on commit 777e990

Please sign in to comment.