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

Black format Repo #407

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
70076fa
README.md
tkrabel-db Jun 5, 2023
ba0f9ad
Add notebook support
tkrabel-db Jun 7, 2023
d5bf4f9
Add example messages for reference
tkrabel-db Jun 7, 2023
78233c7
lsp_types: add DocumentUri and use correctly
tkrabel-db Jun 7, 2023
09d6879
add diagnostics support
tkrabel-db Jun 11, 2023
500e120
support editing, adding, and removing cells
tkrabel-db Jun 12, 2023
b407a31
add unit tests for notebook document messages
tkrabel-db Jun 13, 2023
53e4ad6
add test_notebook_document
tkrabel-db Jun 13, 2023
c891cf0
fix unit tests and pylint
tkrabel-db Jun 13, 2023
3dcaf9f
fix pytest test_notebook_document.py
tkrabel-db Jun 14, 2023
ab3bcee
Fix pylint issues:
tkrabel-db Jun 14, 2023
2dd7165
support notebookDocument__did_close
tkrabel-db Jun 14, 2023
7722239
Add notebookDocumentSync to capabilities
tkrabel-db Jun 15, 2023
6c00bfc
Add notebookDocumentSync to capabilities
tkrabel-db Jun 15, 2023
60517c1
fix: publishDiagnostics line starts at line 0
tkrabel-db Jul 10, 2023
ecc27ee
fix: publishDiagnostics starts at 0 and newlines are counted correctly
tkrabel-db Jul 10, 2023
25cdfab
fix: publishDiagnostics starts at 0 and newlines are counted correctly
tkrabel-db Jul 10, 2023
2b35c95
fix: publishDiagnostics starts at 0 and newlines are counted correctly
tkrabel-db Jul 10, 2023
69a1621
fix: publishDiagnostics starts at 0 and newlines are counted correctly
tkrabel-db Jul 10, 2023
1e9a51f
fix: publishDiagnostics starts at 0 and newlines are counted correctly
tkrabel-db Jul 10, 2023
4f140da
fix: publishDiagnostics starts at 0 and newlines are counted correctly
tkrabel-db Jul 10, 2023
e79bbb2
feat: close cell if deleted
tkrabel-db Jul 20, 2023
ce9f458
skip tests on windows as it's flaky on py3.7
tkrabel-db Jul 22, 2023
5434d1f
fix test_notebook_document__did_change: need to wait for 2 calls to d…
tkrabel-db Jul 24, 2023
db13ca3
black autoformat the repo
tkrabel-db Jul 27, 2023
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
Prev Previous commit
Next Next commit
fix: publishDiagnostics starts at 0 and newlines are counted correctly
  • Loading branch information
tkrabel-db committed Jul 11, 2023
commit 69a1621365a7e384056cd65a4a9157adc256f5d0
3 changes: 1 addition & 2 deletions pylsp/python_lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ def _lint_notebook_document(self, notebook_document, workspace): # pylint: dis
if offset == 0:
total_source = cell_document.source
else:
maybe_newline = "" if total_source.endswith("\n") else "\n"
total_source += (maybe_newline + cell_document.source)
total_source += ("\n" + cell_document.source)

offset += num_lines

Expand Down
18 changes: 2 additions & 16 deletions pylsp/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,19 +519,5 @@ def __init__(self, uri, language_id, workspace, source=None, version=None, local
@property
@lock
def line_count(self):
""""
Return the number of lines in the cell document.

This function is used to combine all cell documents into one text document. Note that we need to count a
newline at the end of a non-empty text line as an extra line.

Examples:
- "x\n" is a cell with two lines, "x" and ""
- "x" is a cell with one line, "x"
- "\n" is a cell with one line, ""
"""
if len(self.lines) == 0:
return 1

last_line = self.lines[-1]
return len(self.lines) + (last_line != "\n" and last_line.endswith("\n"))
""""Return the number of lines in the cell document."""
return len(self.source.split('\n'))
6 changes: 3 additions & 3 deletions test/test_notebook_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def test_notebook_document__did_open(
{
"source": "pyflakes",
"range": {
"start": {"line": 0, "character": 0},
"end": {"line": 0, "character": 11},
"start": {"line": 1, "character": 0},
"end": {"line": 1, "character": 11},
},
"message": "'sys' imported but unused",
"severity": 2,
Expand All @@ -190,7 +190,7 @@ def test_notebook_document__did_open(
"start": {"line": 1, "character": 0},
"end": {"line": 1, "character": 11},
},
"message": "E303 too many blank lines (3)",
"message": "E303 too many blank lines (4)",
"code": "E303",
"severity": 2,
},
Expand Down