Skip to content
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

Replace pkg_resources.parse_version by packaging.version.Version #2037

Merged
merged 2 commits into from
Jan 9, 2024
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
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
Loading