10000 fix unit tests and pylint · tkrabel-db/python-lsp-server@c891cf0 · GitHub
[go: up one dir, main page]

Skip to content

Commit c891cf0

Browse files
committed
fix unit tests and pylint
1 parent 53e4ad6 commit c891cf0

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

pylsp/python_lsp.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
import os
77
import socketserver
88
import threading
9-
import ujson as json
109
import uuid
11-
10+
from typing import List, Dict, Any
11+
import ujson as json
1212

1313
from pylsp_jsonrpc.dispatchers import MethodDispatcher
1414
from pylsp_jsonrpc.endpoint import Endpoint
1515
from pylsp_jsonrpc.streams import JsonRpcStreamReader, JsonRpcStreamWriter
1616

17-
18-
from typing import List, Dict, Any
19-
2017
from . import lsp, _utils, uris
2118
from .config import config
2219
from .workspace import Workspace, Document, Cell, Notebook
@@ -474,11 +471,11 @@ def m_completion_item__resolve(self, **completionItem):
474471
# TODO: add m_notebook_document__did_close
475472
def m_notebook_document__did_open(self, notebookDocument=None, cellTextDocuments=[], **_kwargs):
476473
workspace = self._match_uri_to_workspace(notebookDocument['uri'])
477-
workspace.put_notebook_document(notebookDocument['uri'], notebookDocument['notebookType'],
478-
cells=notebookDocument['cells'], version=notebookDocument.get('version'),
474+
workspace.put_notebook_document(notebookDocument['uri'], notebookDocument['notebookType'],
475+
cells=notebookDocument['cells'], version=notebookDocument.get('version'),
479476
metadata=notebookDocument.get('metadata'))
480477
for cell in cellTextDocuments:
481-
workspace.put_cell_document(cell['uri'], cell['languageId'], notebookDocument['uri'], cell['text'],
478+
workspace.put_cell_document(cell['uri'], cell['languageId'], notebookDocument['uri'], cell['text'],
482479
version=cell.get('version'))
483480
# self._hook('pylsp_document_did_open', textDocument['uri']) # This hook seems only relevant for rope
484481
self.lint(notebookDocument['uri'], is_saved=True)

pylsp/workspace.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ def remove_notebook_cells(self, doc_uri, start, delete_count):
125125

126126
def update_notebook_metadata(self, doc_uri, metadata):
127127
self._docs[doc_uri].metadata = metadata
128-
129-
def put_cell_document(self, doc_uri, language_id, parent, source, version=None):
130-
self._docs[doc_uri] = self._create_cell_document(doc_uri, language_id, parent, source, version)
128+
129+
def put_cell_document(self, doc_uri, language_id, source, version=None):
130+
self._docs[doc_uri] = self._create_cell_document(doc_uri, language_id, source, version)
131131

132132
def rm_document(self, doc_uri):
133133
self._docs.pop(doc_uri)
@@ -275,7 +275,7 @@ def _create_document(self, doc_uri, source=None, version=None):
275275
extra_sys_path=self.source_roots(path),
276276
rope_project_builder=self._rope_project_builder,
277277
)
278-
278+
279279
def _create_notebook_document(self, doc_uri, notebook_type, cells, version=None, metadata=None):
280280
return Notebook(
281281
doc_uri,
@@ -286,14 +286,13 @@ def _create_notebook_document(self, doc_uri, notebook_type, cells, version=None,
286286
metadata=metadata
287287
)
288288

289-
def _create_cell_document(self, doc_uri, language_id, parent, source=None, version=None):
289+
def _create_cell_document(self, doc_uri, language_id, source=None, version=None):
290290
# TODO: remove what is unnecessary here.
291291
path = uris.to_fs_path(doc_uri)
292292
return Cell(
293293
doc_uri,
294294
language_id=language_id,
295295
workspace=self,
296-
parent=parent,
297296
source=source,
298297
version=version,
299298
extra_sys_path=self.source_roots(path),
@@ -497,7 +496,7 @@ def __init__(self, uri, notebook_type, workspace, cells=None, version=None, meta
497496

498497
def __str__(self):
499498
return "Notebook with URI '%s'" % str(self.uri)
500-
499+
501500
def add_cells(self, new_cells: List, start: int) -> None:
502501
self.cells[start:start] = new_cells
503502

@@ -509,8 +508,7 @@ def remove_cells(self, start: int, delete_count: int) -> None:
509508
class Cell(Document):
510509
"""Represents a cell in a notebook."""
511510

512-
def __init__(self, uri, language_id, workspace, parent, source=None, version=None, local=True, extra_sys_path=None,
511+
def __init__(self, uri, language_id, workspace, source=None, version=None, local=True, extra_sys_path=None,
513512
rope_project_builder=None):
514513
super().__init__(uri, workspace, source, version, local, extra_sys_path, rope_project_builder)
515514
self.language_id = language_id
516-
self.parent = parent

0 commit comments

Comments
 (0)
0