From 8a54935f652333267c69ad5a53b16c972c88ed00 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 22 Jul 2023 11:00:28 +0100 Subject: [PATCH] remove unnecessary workaround fixed at --- jedi_language_server/jedi_utils.py | 4 +- jedi_language_server/server.py | 9 +--- poetry.lock | 71 ++++-------------------------- pyproject.toml | 2 +- 4 files changed, 12 insertions(+), 74 deletions(-) diff --git a/jedi_language_server/jedi_utils.py b/jedi_language_server/jedi_utils.py index 5b0f68c..2eed005 100644 --- a/jedi_language_server/jedi_utils.py +++ b/jedi_language_server/jedi_utils.py @@ -328,8 +328,8 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]: def line_column(position: Position) -> Tuple[int, int]: """Translate pygls Position to Jedi's line/column. - Returns a dictionary because this return result should be unpacked as a - function argument to Jedi's functions. + Returns a tuple because this return result should be unpacked as a function + argument to Jedi's functions. Jedi is 1-indexed for lines and 0-indexed for columns. LSP is 0-indexed for lines and 0-indexed for columns. Therefore, add 1 to LSP's request for the diff --git a/jedi_language_server/server.py b/jedi_language_server/server.py index 70f60e2..c1c7494 100644 --- a/jedi_language_server/server.py +++ b/jedi_language_server/server.py @@ -371,21 +371,14 @@ def hover( jedi_script = jedi_utils.script(server.project, document) jedi_lines = jedi_utils.line_column(params.position) markup_kind = _choose_markup(server) - # jedi's help function is buggy when the column is 0. For this reason, as a - # rote fix, we simply set the column to 1 if params.position returns column - # 0. hover_text = jedi_utils.hover_text( - jedi_script.help( - line=jedi_lines[0], - column=1 if jedi_lines[1] == 0 else jedi_lines[1], - ), + jedi_script.help(*jedi_lines), markup_kind, server.initialization_options, ) if not hover_text: return None contents = MarkupContent(kind=markup_kind, value=hover_text) - document = server.workspace.get_document(params.text_document.uri) _range = pygls_utils.current_word_range(document, params.position) return Hover(contents=contents, range=_range) diff --git a/poetry.lock b/poetry.lock index 8f3955e..98262be 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "astroid" version = "2.11.7" description = "An abstract syntax tree for Python with inference support." -category = "dev" optional = false python-versions = ">=3.6.2" files = [ @@ -23,7 +22,6 @@ wrapt = ">=1.11,<2" name = "attrs" version = "22.2.0" description = "Classes Without Boilerplate" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -42,7 +40,6 @@ tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy name = "black" version = "23.1.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -93,7 +90,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "cattrs" version = "22.2.0" description = "Composable complex class support for attrs and dataclasses." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -110,7 +106,6 @@ typing_extensions = {version = "*", markers = "python_version < \"3.8\""} name = "cfgv" version = "3.3.1" description = "Validate configuration and produce human readable error messages." -category = "dev" optional = false python-versions = ">=3.6.1" files = [ @@ -122,7 +117,6 @@ files = [ name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -138,7 +132,6 @@ importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -150,7 +143,6 @@ files = [ name = "coverage" version = "7.2.1" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -217,7 +209,6 @@ toml = ["tomli"] name = "dill" version = "0.3.6" description = "serialize all of python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -232,7 +223,6 @@ graph = ["objgraph (>=1.7.2)"] name = "distlib" version = "0.3.6" description = "Distribution utilities" -category = "dev" optional = false python-versions = "*" files = [ @@ -244,7 +234,6 @@ files = [ name = "docformatter" version = "1.5.0" description = "Formats docstrings to follow PEP 257" -category = "dev" optional = false python-versions = ">=3.6,<4.0" files = [ @@ -263,7 +252,6 @@ tomli = ["tomli (<2.0.0)"] name = "docstring-to-markdown" version = "0.11" description = "On the fly conversion of Python docstrings to markdown" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -275,7 +263,6 @@ files = [ name = "exceptiongroup" version = "1.1.0" description = "Backport of PEP 654 (exception groups)" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -290,7 +277,6 @@ test = ["pytest (>=6)"] name = "filelock" version = "3.9.0" description = "A platform independent file lock." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -306,7 +292,6 @@ testing = ["covdefaults (>=2.2.2)", "coverage (>=7.0.1)", "pytest (>=7.2)", "pyt name = "identify" version = "2.5.18" description = "File identification library for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -321,7 +306,6 @@ license = ["ukkonen"] name = "importlib-metadata" version = "3.10.1" description = "Read metadata from Python packages" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -341,7 +325,6 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pep517", name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -353,7 +336,6 @@ files = [ name = "isort" version = "5.11.5" description = "A Python utility / library to sort Python imports." -category = "dev" optional = false python-versions = ">=3.7.0" files = [ @@ -369,29 +351,27 @@ requirements-deprecated-finder = ["pip-api", "pipreqs"] [[package]] name = "jedi" -version = "0.18.2" +version = "0.19.0" description = "An autocompletion tool for Python that can be used for text editors." -category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "jedi-0.18.2-py2.py3-none-any.whl", hash = "sha256:203c1fd9d969ab8f2119ec0a3342e0b49910045abe6af0a3ae83a5764d54639e"}, - {file = "jedi-0.18.2.tar.gz", hash = "sha256:bae794c30d07f6d910d32a7048af09b5a39ed740918da923c6b780790ebac612"}, + {file = "jedi-0.19.0-py2.py3-none-any.whl", hash = "sha256:cb8ce23fbccff0025e9386b5cf85e892f94c9b822378f8da49970471335ac64e"}, + {file = "jedi-0.19.0.tar.gz", hash = "sha256:bcf9894f1753969cbac8022a8c2eaee06bfa3724e4192470aaffe7eb6272b0c4"}, ] [package.dependencies] -parso = ">=0.8.0,<0.9.0" +parso = ">=0.8.3,<0.9.0" [package.extras] docs = ["Jinja2 (==2.11.3)", "MarkupSafe (==1.1.1)", "Pygments (==2.8.1)", "alabaster (==0.7.12)", "babel (==2.9.1)", "chardet (==4.0.0)", "commonmark (==0.8.1)", "docutils (==0.17.1)", "future (==0.18.2)", "idna (==2.10)", "imagesize (==1.2.0)", "mock (==1.0.1)", "packaging (==20.9)", "pyparsing (==2.4.7)", "pytz (==2021.1)", "readthedocs-sphinx-ext (==2.1.4)", "recommonmark (==0.5.0)", "requests (==2.25.1)", "six (==1.15.0)", "snowballstemmer (==2.1.0)", "sphinx (==1.8.5)", "sphinx-rtd-theme (==0.4.3)", "sphinxcontrib-serializinghtml (==1.1.4)", "sphinxcontrib-websupport (==1.2.4)", "urllib3 (==1.26.4)"] -qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] +qa = ["flake8 (==5.0.4)", "mypy (==0.971)", "types-setuptools (==67.2.0.1)"] testing = ["Django (<3.1)", "attrs", "colorama", "docopt", "pytest (<7.0.0)"] [[package]] name = "lazy-object-proxy" version = "1.9.0" description = "A fast and thorough lazy object proxy." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -437,7 +417,6 @@ files = [ name = "lsprotocol" version = "2022.0.0a10" description = "Python implementation of the Language Server Protocol." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -453,7 +432,6 @@ cattrs = "*" name = "mccabe" version = "0.7.0" description = "McCabe checker, plugin for flake8" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -465,7 +443,6 @@ files = [ name = "mypy" version = "1.0.1" description = "Optional static typing for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -513,7 +490,6 @@ reports = ["lxml"] name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -525,7 +501,6 @@ files = [ name = "nodeenv" version = "1.7.0" description = "Node.js virtual environment builder" -category = "dev" optional = false python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" files = [ @@ -540,7 +515,6 @@ setuptools = "*" name = "packaging" version = "23.0" description = "Core utilities for Python packages" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -552,7 +526,6 @@ files = [ name = "parso" version = "0.8.3" description = "A Python Parser" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -568,7 +541,6 @@ testing = ["docopt", "pytest (<6.0.0)"] name = "pathspec" version = "0.11.0" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -580,7 +552,6 @@ files = [ name = "platformdirs" version = "2.6.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -599,7 +570,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2)", "pytest- name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -618,7 +588,6 @@ testing = ["pytest", "pytest-benchmark"] name = "pre-commit" version = "2.21.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -638,7 +607,6 @@ virtualenv = ">=20.10.0" name = "py" version = "1.11.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ @@ -650,7 +618,6 @@ files = [ name = "pydantic" version = "1.10.5" description = "Data validation and settings management using python type hints" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -703,7 +670,6 @@ email = ["email-validator (>=1.0.3)"] name = "pygls" version = "1.0.1" description = "a pythonic generic language server (pronounced like \"pie glass\")." -category = "main" optional = false python-versions = "<4,>=3.7" files = [ @@ -719,13 +685,12 @@ typeguard = ">=2.10.0,<3" dev = ["bandit (==1.7.4)", "flake8 (==4.0.1)", "mypy (==0.961)"] docs = ["sphinx (==5.0.1)", "sphinx-rtd-theme (==1.0.0)"] test = ["mock (==4.0.3)", "pytest (==7.1.2)", "pytest-asyncio (==0.18.3)"] -ws = ["websockets (>=10.0.0,<11.0.0)"] +ws = ["websockets (==10.*)"] [[package]] name = "pyhamcrest" version = "2.0.4" description = "Hamcrest framework for matcher objects" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -743,7 +708,6 @@ tests-numpy = ["numpy", "pyhamcrest[tests]"] name = "pylint" version = "2.13.9" description = "python code static checker" -category = "dev" optional = false python-versions = ">=3.6.2" files = [ @@ -768,7 +732,6 @@ testutil = ["gitpython (>3)"] name = "pytest" version = "7.2.1" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -793,7 +756,6 @@ testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2. name = "pytest-cov" version = "4.0.0" description = "Pytest plugin for measuring coverage." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -812,7 +774,6 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtuale name = "python-lsp-jsonrpc" version = "1.0.0" description = "JSON RPC 2.0 server library" -category = "dev" optional = false python-versions = "*" files = [ @@ -830,7 +791,6 @@ test = ["coverage", "pycodestyle", "pyflakes", "pylint", "pytest", "pytest-cov"] name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -880,7 +840,6 @@ files = [ name = "setuptools" version = "67.4.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -897,7 +856,6 @@ testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs ( name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -909,7 +867,6 @@ files = [ name = "toml-sort" version = "0.22.4" description = "Toml sorting library" -category = "dev" optional = false python-versions = ">=3.7,<4.0" files = [ @@ -924,7 +881,6 @@ tomlkit = ">=0.11.2" name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -936,7 +892,6 @@ files = [ name = "tomlkit" version = "0.11.6" description = "Style preserving TOML library" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -948,7 +903,6 @@ files = [ name = "tox" version = "3.28.0" description = "tox is a generic virtualenv management and test command line tool" -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ @@ -975,7 +929,6 @@ testing = ["flaky (>=3.4.0)", "freezegun (>=0.3.11)", "pathlib2 (>=2.3.3)", "psu name = "tox-asdf" version = "0.1.0" description = "A plugin telling tox to use asdf to find python executables" -category = "dev" optional = false python-versions = "*" files = [ @@ -993,7 +946,6 @@ test = ["flake8", "mock (>=2.0.0)", "pluggy (>=0.7)", "pytest (>=4.0.0)", "pytes name = "typed-ast" version = "1.5.4" description = "a fork of Python 2 and 3 ast modules with type comment support" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1027,7 +979,6 @@ files = [ name = "typeguard" version = "2.13.3" description = "Run-time type checker for Python" -category = "main" optional = false python-versions = ">=3.5.3" files = [ @@ -1043,7 +994,6 @@ test = ["mypy", "pytest", "typing-extensions"] name = "typing-extensions" version = "4.5.0" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1055,7 +1005,6 @@ files = [ name = "ujson" version = "5.7.0" description = "Ultra fast JSON encoder and decoder for Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1130,7 +1079,6 @@ files = [ name = "untokenize" version = "0.1.1" description = "Transforms tokens into original source code (while preserving whitespace)." -category = "dev" optional = false python-versions = "*" files = [ @@ -1141,7 +1089,6 @@ files = [ name = "virtualenv" version = "20.16.2" description = "Virtual Python Environment builder" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1163,7 +1110,6 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)", name = "wrapt" version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ @@ -1248,7 +1194,6 @@ files = [ name = "zipp" version = "3.15.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1263,4 +1208,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.7,<4" -content-hash = "396deceb539709c25442caefeb33e850769478f73fecc91a89c7ab22e5007f2b" +content-hash = "3e0084892376828b46fdd3c424898697b9cb33bd9c5a513f9c2a9bd7731188c9" diff --git a/pyproject.toml b/pyproject.toml index 878de84..95f3e1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ license = "MIT" [tool.poetry.dependencies] python = "^3.7,<4" -jedi = "^0.18.1" +jedi = "^0.19.0" pygls = "^1.0.1" pydantic = "^1.9.1" docstring-to-markdown = "0.*"