Skip to content

Commit

Permalink
Use pkg_resources as fallback for parse_version
Browse files Browse the repository at this point in the history
  • Loading branch information
berhoel committed Dec 17, 2023
1 parent a7ae274 commit 6a6655e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions elpy/blackutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
try:
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
11 changes: 7 additions & 4 deletions elpy/jedibackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
try:
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 6a6655e

Please sign in to comment.