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

Implement rudimentary compatibility with jedi 18.0 #1916

Merged
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
10 changes: 10 additions & 0 deletions elpy/json_encoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import json
import pathlib


class JSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, pathlib.Path):
return str(o)
else:
return super().default(o)
4 changes: 3 additions & 1 deletion elpy/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import json
import sys
import traceback
from .json_encoder import JSONEncoder


class JSONRPCServer(object):
Expand Down Expand Up @@ -74,7 +75,8 @@ def write_json(self, **kwargs):
It's not possible with this method to write non-objects.

"""
self.stdout.write(json.dumps(kwargs) + "\n")
serialized_value = JSONEncoder().encode(kwargs)
self.stdout.write(serialized_value + "\n")
self.stdout.flush()

def handle_request(self):
Expand Down
9 changes: 5 additions & 4 deletions elpy/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
"""

import os
import pathlib
import re
import shutil
import sys
import tempfile
import unittest
import re

from elpy.tests import compat
from elpy.rpc import Fault
from elpy import jedibackend
from elpy.rpc import Fault
from elpy.tests import compat


class BackendTestCase(unittest.TestCase):
Expand Down Expand Up @@ -55,7 +56,7 @@ def project_file(self, relname, contents):
fobj = open(full_name, "w")
with fobj as f:
f.write(contents)
return full_name
return pathlib.Path(full_name)


class GenericRPCTests(object):
Expand Down
2 changes: 1 addition & 1 deletion requirements-rpc.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jedi==0.17.2
jedi==0.18.0
rope==0.17.0
autopep8==1.5.4
yapf==0.30
Expand Down