Skip to content

Commit a7affc3

Browse files
authored
Merge pull request pappasam#276 from dimbleby/fixes-and-updates
Fixes and updates
2 parents 6b064bc + 38aa42e commit a7affc3

File tree

11 files changed

+745
-630
lines changed

11 files changed

+745
-630
lines changed

.github/workflows/testing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
strategy:
4848
matrix:
4949
os: [ubuntu-latest, windows-latest]
50-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
50+
python-version: ["3.8", "3.9", "3.10", "3.11"]
5151
steps:
5252
- name: Checkout
5353
uses: actions/checkout@v2

.pylintrc

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
[MASTER]
2-
# Profiled execution.
3-
profile=no
4-
52
# Add files or directories to the blacklist. They should be base names, not
63
# paths.
74
ignore=CVS, .svn, .git, venv
@@ -18,7 +15,7 @@ extension-pkg-whitelist=pydantic
1815

1916
[MESSAGES CONTROL]
2017
# can opt to enable instead if you want
21-
disable=logging-format-interpolation, bad-continuation
18+
disable=logging-format-interpolation
2219

2320
[REPORTS]
2421

@@ -27,11 +24,6 @@ disable=logging-format-interpolation, bad-continuation
2724
# mypackage.mymodule.MyReporterClass.
2825
output-format=colorized
2926

30-
# Put messages in a separate file for each module / package specified on the
31-
# command line instead of printing them on stdout. Reports (if any) will be
32-
# written in a file name "pylint_global.[txt|html]".
33-
files-output=no
34-
3527
# Tells whether to display a full report or only the messages
3628
reports=no
3729

@@ -42,11 +34,6 @@ reports=no
4234
# (RP0004).
4335
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
4436

45-
# Add a comment according to your evaluation note. This is used by the global
46-
# evaluation report (RP0004).
47-
comment=no
48-
49-
5037
[MISCELLANEOUS]
5138

5239
# List of note tags to take in consideration, separated by a comma.
@@ -184,7 +171,7 @@ max-locals=15
184171
max-returns=6
185172

186173
# Maximum number of branch for function / method body
187-
max-branchs=12
174+
max-branches=12
188175

189176
# Maximum number of statements in function / method body
190177
max-statements=50
@@ -224,4 +211,4 @@ int-import-graph=
224211

225212
# Exceptions that will emit a warning when being caught. Defaults to
226213
# "Exception"
227-
overgeneral-exceptions=Exception
214+
overgeneral-exceptions=builtins.Exception

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
[![image-version](https://img.shields.io/pypi/v/jedi-language-server.svg)](https://python.org/pypi/jedi-language-server)
44
[![image-license](https://img.shields.io/pypi/l/jedi-language-server.svg)](https://python.org/pypi/jedi-language-server)
5-
[![image-python-versions](https://img.shields.io/badge/python->=3.7-blue)](https://python.org/pypi/jedi-language-server)
5+
[![image-python-versions](https://img.shields.io/badge/python->=3.8-blue)](https://python.org/pypi/jedi-language-server)
66
[![image-pypi-downloads](https://pepy.tech/badge/jedi-language-server)](https://pepy.tech/project/jedi-language-server)
77
[![github-action-testing](https://github.com/pappasam/jedi-language-server/actions/workflows/testing.yaml/badge.svg)](https://github.com/pappasam/jedi-language-server/actions/workflows/testing.yaml)
88

9-
A [Language Server](https://microsoft.github.io/language-server-protocol/) for the latest version(s) of [Jedi](https://jedi.readthedocs.io/en/latest/). If using Neovim/Vim, we recommend using with [coc-jedi](https://github.com/pappasam/coc-jedi). Supports Python versions 3.7 and newer.
9+
A [Language Server](https://microsoft.github.io/language-server-protocol/) for the latest version(s) of [Jedi](https://jedi.readthedocs.io/en/latest/). If using Neovim/Vim, we recommend using with [coc-jedi](https://github.com/pappasam/coc-jedi). Supports Python versions 3.8 and newer.
1010

1111
**Note:** this tool is actively used by its primary author. He's happy to review pull requests / respond to issues you may discover.
1212

jedi_language_server/initialization_options.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import List, Optional, Pattern, Set
88

99
from lsprotocol.types import MarkupKind
10-
from pydantic import BaseModel, Field
10+
from pydantic import BaseModel, ConfigDict, Field
1111

1212
# pylint: disable=missing-class-docstring
1313
# pylint: disable=too-few-public-methods
@@ -22,8 +22,7 @@ def snake_to_camel(string: str) -> str:
2222

2323

2424
class Model(BaseModel):
25-
class Config:
26-
alias_generator = snake_to_camel
25+
model_config = ConfigDict(alias_generator=snake_to_camel)
2726

2827

2928
class CodeAction(Model):
@@ -34,8 +33,7 @@ class CodeAction(Model):
3433
class Completion(Model):
3534
disable_snippets: bool = False
3635
resolve_eagerly: bool = False
37-
# <https://github.com/pydantic/pydantic/issues/2636>
38-
ignore_patterns: List[Pattern] = [] # type: ignore[type-arg]
36+
ignore_patterns: List[Pattern[str]] = []
3937

4038

4139
class Diagnostics(Model):
@@ -116,5 +114,5 @@ class InitializationOptions(Model):
116114
diagnostics: Diagnostics = Diagnostics()
117115
hover: Hover = Hover()
118116
jedi_settings: JediSettings = JediSettings()
119-
markup_kind_preferred: Optional[MarkupKind]
117+
markup_kind_preferred: Optional[MarkupKind] = None
120118
workspace: Workspace = Workspace()

jedi_language_server/jedi_utils.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]:
308308
until_column = (
309309
_until_column - 1 if _until_column is not None else column + 1
310310
)
311-
until_line = _until_line - 1 if _until_line is not None else line + 1
311+
until_line = _until_line - 1 if _until_line is not None else line
312312

313313
if (line, column) >= (until_line, until_column):
314314
until_column, until_line = column, line
@@ -328,8 +328,8 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]:
328328
def line_column(position: Position) -> Tuple[int, int]:
329329
"""Translate pygls Position to Jedi's line/column.
330330
331-
Returns a dictionary because this return result should be unpacked as a
332-
function argument to Jedi's functions.
331+
Returns a tuple because this return result should be unpacked as a function
332+
argument to Jedi's functions.
333333
334334
Jedi is 1-indexed for lines and 0-indexed for columns. LSP is 0-indexed for
335335
lines and 0-indexed for columns. Therefore, add 1 to LSP's request for the
@@ -352,19 +352,19 @@ def line_column(position: Position) -> Tuple[int, int]:
352352
def line_column_range(pygls_range: Range) -> Dict[str, int]:
353353
"""Translate pygls range to Jedi's line/column/until_line/until_column.
354354
355-
Returns a dictionary because this return result should be unpacked as a
356-
function argument to Jedi's functions.
355+
Returns a dictionary because this return result should be unpacked
356+
as a function argument to Jedi's functions.
357357
358-
Jedi is 1-indexed for lines and 0-indexed for columns. LSP is 0-indexed for
359-
lines and 0-indexed for columns. Therefore, add 1 to LSP's request for the
360-
line.
358+
Jedi is 1-indexed for lines and 0-indexed for columns. LSP is
359+
0-indexed for lines and 0-indexed for columns. Therefore, add 1 to
360+
LSP's request for the line.
361361
"""
362-
return dict(
363-
line=pygls_range.start.line + 1,
364-
column=pygls_range.start.character,
365-
until_line=pygls_range.end.line + 1,
366-
until_column=pygls_range.end.character,
367-
)
362+
return {
363+
"line": pygls_range.start.line + 1,
364+
"column": pygls_range.start.character,
365+
"until_line": pygls_range.end.line + 1,
366+
"until_column": pygls_range.end.character,
367+
}
368368

369369

370370
def compare_names(name1: Name, name2: Name) -> bool:
@@ -381,12 +381,12 @@ def compare_names(name1: Name, name2: Name) -> bool:
381381
def complete_sort_name(name: Completion, append_text: str) -> str:
382382
"""Return sort name for a jedi completion.
383383
384-
Should be passed to the sortText field in CompletionItem. Strings sort a-z,
385-
a comes first and z comes last.
384+
Should be passed to the sortText field in CompletionItem. Strings
385+
sort a-z, a comes first and z comes last.
386386
387-
Additionally, we'd like to keep the sort order to what Jedi has provided.
388-
For this reason, we make sure the sort-text is just a letter and not the
389-
name itself.
387+
Additionally, we'd like to keep the sort order to what Jedi has
388+
provided. For this reason, we make sure the sort-text is just a
389+
letter and not the name itself.
390390
"""
391391
name_str = name.name
392392
if name_str is None:

jedi_language_server/server.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,21 +371,14 @@ def hover(
371371
jedi_script = jedi_utils.script(server.project, document)
372372
jedi_lines = jedi_utils.line_column(params.position)
373373
markup_kind = _choose_markup(server)
374-
# jedi's help function is buggy when the column is 0. For this reason, as a
375-
# rote fix, we simply set the column to 1 if params.position returns column
376-
# 0.
377374
hover_text = jedi_utils.hover_text(
378-
jedi_script.help(
379-
line=jedi_lines[0],
380-
column=1 if jedi_lines[1] == 0 else jedi_lines[1],
381-
),
375+
jedi_script.help(*jedi_lines),
382376
markup_kind,
383377
server.initialization_options,
384378
)
385379
if not hover_text:
386380
return None
387381
contents = MarkupContent(kind=markup_kind, value=hover_text)
388-
document = server.workspace.get_document(params.text_document.uri)
389382
_range = pygls_utils.current_word_range(document, params.position)
390383
return Hover(contents=contents, range=_range)
391384

jedi_language_server/text_edit_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def lsp_text_edits(
9797
9898
Handles inserts, replaces, and deletions within a text file.
9999
100-
Additionally, makes sure returned code is syntactically valid Python.
100+
Additionally, makes sure returned code is syntactically valid
101+
Python.
101102
"""
102103
new_code = changed_file.get_new_code()
103104
if not is_valid_python(new_code):

0 commit comments

Comments
 (0)