Giter VIP home page Giter VIP logo

lsp-pylsp's People

Contributors

dependabot[bot] avatar jackenmen avatar jfcherng avatar predragnikolic avatar rchl avatar rwols avatar stabbarn avatar yaroslavyaroslav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lsp-pylsp's Issues

No expandpath in path variables

I would like configure the default jedi environment like this:

{
    "settings": {
        "pylsp.plugins.jedi.environment": "~/.virtualenvs/${project_base_name}",
    }
}

However, the plugin does not expand "~" into my home directory path. Could an expandpath be added on the settings variables that hold a path? (I don't know how to do that, otherwise I would have filed a pull request)

Plugin getting installed under the wrong version of python?

I'm on SublimeText 4169. I've just upgraded SublimeText because I started getting LSP-pylsp failures last month (see error below).

As far as I understand, mypy 1.8.0 is not available for python 3.3. And the newest SublimeText plugin API should be python 3.8. However, when I uninstall and re-install LSP-pylsp, it appears to be installing via python 3.3:

Package Control: Installed package "LSP-pylsp" 2.18.0
reloading settings Packages/LSP-pylsp/LSP-pylsp.sublime-settings
reloading python 3.3 plugin LSP-pylsp.plugin

The error that popups once the plugin is loaded:

--- Error: ---
Error installing the server:
Collecting mypy==1.8.0 (from -r /Users/xxx/Library/Caches/Sublime Text 3/Package Storage/LSP-pylsp/requirements.txt (line 1))
Could not find a version that satisfies the requirement mypy==1.8.0 (from -r /Users/xxx/Library/Caches/Sublime Text 3/Package Storage/LSP-pylsp/requirements.txt (line 1)) (from versions: 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.221, 0.222, 0.223, 0.224, 0.225, 0.226, 0.227, 0.228, 0.229, 0.230, 0.231, 0.232, 0.233, 0.234, 0.235, 0.236, 0.237, 0.238, 0.239, 0.240, 0.241, 0.250, 0.251, 0.252, 0.253, 0.254, 0.255, 0.256, 0.470, 0.471, 0.501, 0.510, 0.511, 0.520, 0.521, 0.530, 0.540, 0.550, 0.560, 0.570, 0.580, 0.590, 0.600, 0.610, 0.620, 0.630, 0.641, 0.650, 0.660, 0.670, 0.700, 0.701, 0.710, 0.711, 0.720, 0.730, 0.740, 0.750, 0.760, 0.761, 0.770, 0.780, 0.781, 0.782, 0.790, 0.800, 0.812, 0.900, 0.901, 0.902, 0.910, 0.920, 0.921, 0.930, 0.931, 0.940, 0.941, 0.942, 0.950, 0.960, 0.961, 0.971, 0.981, 0.982, 0.990, 0.991, 1.0.0, 1.0.1, 1.1.1, 1.2.0, 1.3.0, 1.4.0, 1.4.1)
No matching distribution found for mypy==1.8.0 (from -r /Users/xxx/Library/Caches/Sublime Text 3/Package Storage/LSP-pylsp/requirements.txt (line 1))

Error on install when "wheels" is missing

My python has updated through brew and now I'm getting this:

Screenshot 2020-12-07 at 21 24 15

I haven't tried fixing it yet but it's not a great message to show in the user's face.

According to allenai/document-qa#47 I might have to install some dependencies globally but that doesn't sound like a good solution.

missing docstring_to_markdown package

Hi,

I recently started having the issue shown below, and I'm not sure how to troubleshoot further.

Troubleshooting: LSP-pylsp

Version

  • LSP: 1.25.0
  • Sublime Text: 4152

Server Test Run

  • exit code: 1
  • output
Traceback (most recent call last):
  File "C:\local\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\local\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\local\st3\Data\Package Storage\LSP-pylsp\Scripts\pylsp.exe\__main__.py", line 5, in <module>
  File "c:\local\st3\data\package storage\lsp-pylsp\lib\site-packages\pylsp\__main__.py", line 15, in <module>
    from .python_lsp import (PythonLSPServer, start_io_lang_server,
  File "c:\local\st3\data\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 15, in <module>
    from . import lsp, _utils, uris
  File "c:\local\st3\data\package storage\lsp-pylsp\lib\site-packages\pylsp\_utils.py", line 13, in <module>
    import docstring_to_markdown
ModuleNotFoundError: No module named 'docstring_to_markdown'

Server Configuration

  • command
[
  "$server_path"
]
  • shell command
"C:\local\st3\Data\Package Storage\LSP-pylsp\Scripts\pylsp.exe"
  • selector
source.python
  • priority_selector
(source.python)
  • init_options
{}
  • settings
{
  "pylsp": {
    "configurationSources": [
      "pycodestyle"
    ], 
    "plugins": {
      "autopep8": {
        "enabled": true
      }, 
      "flake8": {
        "config": null, 
        "enabled": false, 
        "exclude": null, 
        "executable": "flake8", 
        "filename": null, 
        "hangClosing": null, 
        "ignore": null, 
        "maxLineLength": 120, 
        "perFileIgnores": null, 
        "select": null
      }, 
      "jedi": {
        "auto_import_modules": [
          "numpy"
        ], 
        "env_vars": null, 
        "environment": null, 
        "extra_paths": [
          "$sublime_py_files_dir", 
          "$packages"
        ]
      }, 
      "jedi_completion": {
        "cache_for": [
          "pandas", 
          "numpy", 
          "tensorflow", 
          "matplotlib"
        ], 
        "eager": false, 
        "enabled": false, 
        "fuzzy": true, 
        "include_class_objects": false, 
        "include_function_objects": false, 
        "include_params": true, 
        "resolve_at_most": 25
      }, 
      "jedi_definition": {
        "enabled": false, 
        "follow_builtin_imports": true, 
        "follow_imports": true
      }, 
      "jedi_hover": {
        "enabled": false
      }, 
      "jedi_references": {
        "enabled": false
      }, 
      "jedi_signature_help": {
        "enabled": false
      }, 
      "jedi_symbols": {
        "all_scopes": true, 
        "enabled": false, 
        "include_import_symbols": true
      }, 
      "mccabe": {
        "enabled": true, 
        "threshold": 15
      }, 
      "preload": {
        "enabled": true, 
        "modules": null
      }, 
      "pycodestyle": {
        "aggressive": 1, 
        "enabled": true, 
        "exclude": null, 
        "filename": null, 
        "hangClosing": null, 
        "ignore": null, 
        "maxLineLength": 120, 
        "select": null
      }, 
      "pydocstyle": {
        "addIgnore": null, 
        "addSelect": null, 
        "convention": null, 
        "enabled": false, 
        "ignore": null, 
        "match": "(?!test_).*\\.py", 
        "matchDir": "[^\\.].*", 
        "select": null
      }, 
      "pyflakes": {
        "enabled": false
      }, 
      "pylint": {
        "args": null, 
        "enabled": false, 
        "executable": ""
      }, 
      "pyls_isort": {
        "enabled": true
      }, 
      "pylsp_black": {
        "cache_config": false, 
        "enabled": false, 
        "line_length": 120, 
        "preview": false
      }, 
      "pylsp_mypy": {
        "dmypy": false, 
        "enabled": false, 
        "live_mode": false, 
        "strict": false
      }, 
      "rope_completion": {
        "eager": false, 
        "enabled": false
      }, 
      "yapf": {
        "enabled": false
      }
    }, 
    "rope": {
      "extensionModules": null, 
      "ropeFolder": null
    }
  }
}
  • env
{
  "HTTPS_PROXY": "http://x.x.x.x:xx", 
  "HTTP_PROXY": "http://x.x.x.x:xx", 
  "PATH": "C:\\local\\st3\\Data\\Package Storage\\LSP-pylsp\\Scripts;", 
  "PYTHONPATH": "${sublime_py_files_dir}${pathsep}${packages}"
}

Active view

  • File name
Z:\home\...
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", 
  "lsp_active": true, 
  "syntax": "Packages/MagicPython/grammars/MagicPython.tmLanguage"
}
  • base scope
source.python

Project / Workspace

  • folders
[
  "Z:\\home\\..."
]
  • is project: True
  • project data:
{
  "folders": [
    {
      "path": "."
    }
  ]
}

LSP configuration

## System PATH - C:\Program Files (x86)\Common Files\Oracle\Java\javapath - C:\WINDOWS\system32 - C:\WINDOWS - C:\WINDOWS\System32\Wbem - C:\WINDOWS\System32\WindowsPowerShell\v1.0\ - C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common - C:\WINDOWS\system32 - C:\WINDOWS - C:\WINDOWS\System32\Wbem - C:\WINDOWS\System32\WindowsPowerShell\v1.0\ - C:\WINDOWS\System32\OpenSSH\ - C:\local\node-v16.13.1 - C:\local\python38\Scripts\ - C:\local\python38\ - C:\Users\jworne\AppData\Local\Programs\Python\Launcher\ - C:\Python37\Scripts\ - C:\Python37\ - C:\local\python-3.7 - C:\local\Sublime Text Build 3083 x64 - C:\Users\jworne\AppData\Local\Microsoft\WindowsApps - C:\Program Files (x86)\Common Files\Oracle\Java\javapath - C:\WINDOWS\system32 - C:\WINDOWS - C:\WINDOWS\System32\Wbem - C:\WINDOWS\System32\WindowsPowerShell\v1.0\ - C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common - C:\WINDOWS\system32 - C:\WINDOWS - C:\WINDOWS\System32\Wbem - C:\WINDOWS\System32\WindowsPowerShell\v1.0\ - C:\WINDOWS\System32\OpenSSH\ - - C:\Users\jworne\AppData\Local\Programs\Microsoft VS Code\bin

Flake8 config file rules are not applied on linting

Issue:

  • tox.ini is not considered by flake8
  • pycodestyle is triggered despite the fact that I set its settings to false

I tried several methods but nothing works. A simple test with an E501 error because triggers:

   13:80  warning E501 line too long (80 > 79 characters) ​pycodestyle:E501
   13:80  warning E501 line too long (80 > 79 characters) ​flake8:E501

Despite the fact that my tox.ini is configured like this:

[flake8]
    ignore = E226,E302,E41
    max-line-length = 120

My ST project is configured as follows:

LSP Settings :

{
    "clients": {
        "pylsp": {
            "enabled": false,
            "selector": "source.python",
            "settings": {
                "pylsp.plugins.pyflakes.enabled": false, 
                "pylsp.plugins.pycodestyle.enabled": false, 
                "pylsp.plugins.flake8.enabled": true, 
                "pylsp.configurationSources": ["flake8"],
                "pylsp.plugins.jedi_rename.enabled": true,
                "pylsp.plugins.autopep8.enabled": false,  
                "pylsp.plugins.yapf.enabled": false,  
                "pylsp.plugins.black.enabled": true, 
                "pylsp.plugins.mypy_ls.enabled": true
}}}}

Py-lsp settings :

{
    "pylsp.plugins.mypy-ls.enabled": true,
    "pylsp.plugins.flake8.enabled": true,
    "pylsp.configurationSources": [ "flake8"],
    "pylsp.plugins.pyls_black.enabled": true,
    "pylsp.plugins.flake8.config": "~/.config/flake8/tox.ini"
}

Project settings

{
    "folders": [
        {
            "path": ".",
        },
    ],
    "settings": {
        "python_interpreter": "~/Library/Caches/pypoetry/virtualenvs/base-hkX03Jqr-py3.10/bin/python3",
        "LSP": {
            "pylsp": {
                "enabled": true,
                "command": [
                    "~/Library/Caches/pypoetry/virtualenvs/base-hkX03Jqr-py3.10/bin/pylsp",
                ],
                "settings": {
                    "pylsp.plugins.flake8.executable": "~/Library/Caches/pypoetry/virtualenvs/base-hkX03Jqr-py3.10/bin/flake8",
                },
            },
        },
    },
    "build_systems": [
        {
            "name": "Base Python Build",
            "cmd": [
                "~/Library/Caches/pypoetry/virtualenvs/base-hkX03Jqr-py3.10/bin/python3",
                "-u",
                "$file"
            ],
            "selector": "source.python",
            "file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)",
        }
    ],
}

All is working great, linting, mypy hints etc. but my linting prefs via flake8 config file is not impacting the error.
EDIT: with a minimal description of my python env managed by Poetry and with python-lsp-server[all], python-lsp-black, mypy-ls and pyls-isort added.

No linter diagnostics reported

Hey! Trying to use LSP-pyls in a project, I can get code completion working, but not any of the linters

  • Running on Mac
  • LSP version 1.2.12
  • Sublime Text 4099
  • Using poetry for package/venv management
  • I have no user-visible errors

User settings file

// Settings in here override those in "LSP-pyls/LSP-pyls.sublime-settings"

{
  "settings": {
    "pyls.configurationSources": ["flake8"],
    "pyls.plugins.pycodestyle.enabled": false,
    "pyls.plugins.flake8_lint.enabled": true,
    "pyls.plugins.pyls_mypy.enabled": true,
    "pyls.plugins.pyls_mypy.live_mode": false,
    "pyls.plugins.pyls_black.enabled": true,
    "pyls.plugins.pyls_isort.enabled": true,
  },
}

What I expect

To get mypy/flake8 warnings/diagnostics shown in Sublime.
Renames, code-completion and go-to-reference is working, the things I expect are depending on JEDI.

What I've tried

Enabling the different linters from the overall lsp settings under the pyls key, the lsp-pyls settings, and project settings.
Since I'm using poetry, I thought something might be up with the PATH vars, to I tried adding the env section to these different locations as well, but it didn't work either.

  "env": {
    "PYTHONPATH": "$sublime_py_files_dir:$packages:/Users/username/Library/Caches/pypoetry/virtualenvs/backend-GAy6QZlK-py3.8",
    "MYPY_PATH": "$sublime_py_files_dir:$packages:/Users/username/Library/Caches/pypoetry/virtualenvs/backend-GAy6QZlK-py3.8"
  },

Where to put autopep8 custom configurations ?

I am using autopep8 as formatter. I want to have a custom configuration for autopep8. Where exactly do I put my configurations into ? Can I put key-values like this somewhere in LSP.sublime-settings Or LSP-pylsp.sublime-settings file (or maybe in project specific "settings": { }) ?

I am quite new to sublime, so sorry if the question is basic.

The virtual environment configured in the project does not work

Configuration of my project:

{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"LSP": {
			"LSP-pylsp": {
				"settings": {
					"pylsp.plugins.jedi.environment": "/Users/thepoy/venvs/spider"
				}
			}
		},
	}
}

Although there is no error or exception thrown, none of the packages in the virtual environment can be prompted or automatically completed.

Virtual environment directory structure:

.
├── bin
├── include
├── lib
│   └── python3.8
│       └── site-packages
└── share

It can be seen that it is a virtual environment generated by python3-venv.

jedi.api.environment.InvalidPythonEnvironment: Could not get version information for '.\\venv\\Scripts\\python.exe': OSError(22, 'The parameter is incorrect', None, 87, None)

I am picking up work on a Python project again and now I get an exception in the pylsp service. From what I remember everything was working just fine two months ago, during I did not touch this environment. However, there obviously were package updates on the Sublime Text side.

Anyways, any ideas on how to debug and figure out what could be going wrong? Maybe this issue should be reported on the jedi side of things?

  • Windows 10
  • Python version 3.9.5 en 3.9.6 (tested both)
  • Sublime Text 4 (4113)
// Settings in here override those in "LSP-pylsp/LSP-pylsp.sublime-settings"
{
	"settings": {
		"pylsp.plugins.autopep8.enabled": false,
		"pylsp.plugins.pylsp_black.enabled": true,
		"pylsp.plugins.pyls_isort.enabled": true,
		"pylsp.plugins.jedi.environment": ".\\venv",

		// Pycodestyle settings
		"pylsp.plugins.pycodestyle.ignore": ["E501", "W503", "E203"],
		"pylsp.plugins.pycodestyle.exclude": ["venv\\**"]
	}
}
::  -> LSP-pylsp textDocument/didChange: <params with 14255 characters>
LSP-pylsp: 2021-08-23 09:32:02,756 W. Europe Daylight Time - ERROR - pylsp_jsonrpc.endpoint - Failed to handle request 219
LSP-pylsp: Traceback (most recent call last):
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\cache.py", line 110, in wrapper
LSP-pylsp:     return dct[key]
LSP-pylsp: KeyError: ((), frozenset())
LSP-pylsp: 
LSP-pylsp: During handling of the above exception, another exception occurred:
LSP-pylsp: 
LSP-pylsp: Traceback (most recent call last):
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\api\environment.py", line 77, in _get_subprocess
LSP-pylsp:     info = self._subprocess._send(None, _get_info)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\inference\compiled\subprocess\__init__.py", line 237, in _send
LSP-pylsp:     pickle_dump(data, self._get_process().stdin, PICKLE_PROTOCOL)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\cache.py", line 112, in wrapper
LSP-pylsp:     result = method(self, *args, **kwargs)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\inference\compiled\subprocess\__init__.py", line 193, in _get_process
LSP-pylsp:     process = _GeneralizedPopen(
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\inference\compiled\subprocess\__init__.py", line 43, in _GeneralizedPopen
LSP-pylsp:     return subprocess.Popen(*args, **kwargs)
LSP-pylsp:   File "C:\ProgramData\pyenv\pyenv-win\versions\3.9.6\lib\subprocess.py", line 951, in __init__
LSP-pylsp:     self._execute_child(args, executable, preexec_fn, close_fds,
LSP-pylsp:   File "C:\ProgramData\pyenv\pyenv-win\versions\3.9.6\lib\subprocess.py", line 1420, in _execute_child
LSP-pylsp:     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
LSP-pylsp: OSError: [WinError 87] The parameter is incorrect
LSP-pylsp: 
LSP-pylsp: During handling of the above exception, another exception occurred:
LSP-pylsp: 
LSP-pylsp: Traceback (most recent call last):
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\endpoint.py", line 116, in consume
LSP-pylsp:     self._handle_request(message['id'], message['method'], message.get('params'))
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\endpoint.py", line 185, in _handle_request
LSP-pylsp:     handler_result = handler(params)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\dispatchers.py", line 25, in handler
LSP-pylsp:     return method(**(params or {}))
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 356, in m_text_document__document_highlight
LSP-pylsp:     return self.highlight(textDocument['uri'], position)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 287, in highlight
LSP-pylsp:     return flatten(self._hook('pylsp_document_highlight', doc_uri, position=position)) or None
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 156, in _hook
LSP-pylsp:     return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\hooks.py", line 286, in __call__
LSP-pylsp:     return self._hookexec(self, self.get_hookimpls(), kwargs)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
LSP-pylsp:     return self._inner_hookexec(hook, methods, kwargs)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\manager.py", line 337, in traced_hookexec
LSP-pylsp:     return outcome.get_result()
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\callers.py", line 80, in get_result
LSP-pylsp:     raise ex[1].with_traceback(ex[2])
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\callers.py", line 52, in from_call
LSP-pylsp:     result = func()
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\manager.py", line 335, in <lambda>
LSP-pylsp:     outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\manager.py", line 84, in <lambda>
LSP-pylsp:     self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\callers.py", line 208, in _multicall
LSP-pylsp:     return outcome.get_result()
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\callers.py", line 80, in get_result
LSP-pylsp:     raise ex[1].with_traceback(ex[2])
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pluggy\callers.py", line 187, in _multicall
LSP-pylsp:     res = hook_impl.function(*args)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\plugins\highlight.py", line 13, in pylsp_document_highlight
LSP-pylsp:     usages = document.jedi_script().get_references(**code_position)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\workspace.py", line 27, in wrapper
LSP-pylsp:     return method(self, *args, **kwargs)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\workspace.py", line 265, in jedi_script
LSP-pylsp:     environment = self.get_enviroment(environment_path, env_vars=env_vars) if environment_path else None
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\pylsp\workspace.py", line 294, in get_enviroment
LSP-pylsp:     environment = jedi.api.environment.create_environment(path=environment_path,
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\api\environment.py", line 367, in create_environment
LSP-pylsp:     return Environment(_get_executable_path(path, safe=safe), env_vars=env_vars)
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\api\environment.py", line 68, in __init__
LSP-pylsp:     self._get_subprocess()
LSP-pylsp:   File "<sublime path>\data\package storage\lsp-pylsp\lib\site-packages\jedi\api\environment.py", line 79, in _get_subprocess
LSP-pylsp:     raise InvalidPythonEnvironment(
LSP-pylsp: jedi.api.environment.InvalidPythonEnvironment: Could not get version information for '.\\venv\\Scripts\\python.exe': OSError(22, 'The parameter is incorrect', None, 87, None)
:: <~~ LSP-pylsp 219: {'message': "jedi.api.environment.InvalidPythonEnvironment: Could not get version information for '.\\\\venv\\\\Scripts\\\\python.exe': OSError(22, 'The parameter is incorrect', None, 87, None)", 'code': -32602, 'data': {'traceback': ['  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp_jsonrpc\\endpoint.py", line 116, in consume\n    self._handle_request(message[\'id\'], message[\'method\'], message.get(\'params\'))\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp_jsonrpc\\endpoint.py", line 185, in _handle_request\n    handler_result = handler(params)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp_jsonrpc\\dispatchers.py", line 25, in handler\n    return method(**(params or {}))\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\python_lsp.py", line 356, in m_text_document__document_highlight\n    return self.highlight(textDocument[\'uri\'], position)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\python_lsp.py", line 287, in highlight\n    return flatten(self._hook(\'pylsp_document_highlight\', doc_uri, position=position)) or None\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\python_lsp.py", line 156, in _hook\n    return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\hooks.py", line 286, in __call__\n    return self._hookexec(self, self.get_hookimpls(), kwargs)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\manager.py", line 93, in _hookexec\n    return self._inner_hookexec(hook, methods, kwargs)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\manager.py", line 337, in traced_hookexec\n    return outcome.get_result()\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\callers.py", line 80, in get_result\n    raise ex[1].with_traceback(ex[2])\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\callers.py", line 52, in from_call\n    result = func()\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\manager.py", line 335, in <lambda>\n    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\manager.py", line 84, in <lambda>\n    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\callers.py", line 208, in _multicall\n    return outcome.get_result()\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\callers.py", line 80, in get_result\n    raise ex[1].with_traceback(ex[2])\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pluggy\\callers.py", line 187, in _multicall\n    res = hook_impl.function(*args)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\plugins\\highlight.py", line 13, in pylsp_document_highlight\n    usages = document.jedi_script().get_references(**code_position)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\workspace.py", line 27, in wrapper\n    return method(self, *args, **kwargs)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\workspace.py", line 265, in jedi_script\n    environment = self.get_enviroment(environment_path, env_vars=env_vars) if environment_path else None\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\pylsp\\workspace.py", line 294, in get_enviroment\n    environment = jedi.api.environment.create_environment(path=environment_path,\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\jedi\\api\\environment.py", line 367, in create_environment\n    return Environment(_get_executable_path(path, safe=safe), env_vars=env_vars)\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\jedi\\api\\environment.py", line 68, in __init__\n    self._get_subprocess()\n', '  File "<sublime path>\\data\\package storage\\lsp-pylsp\\lib\\site-packages\\jedi\\api\\environment.py", line 79, in _get_subprocess\n    raise InvalidPythonEnvironment(\n']}}
:: <<< LSP-pylsp 220: []

Mypy does not follow jedi.environment

For instance, when specifying a Poetry virtualenv through pylsp.plugins.jedi.environment, Mypy will not use it, and provide completely broken results.

Additionally, native Poetry support (akin to what vim-ale does) would be a great addition.

Remove cache data on unloading

Like other LSP packages do, this one should also remove the cache data on plugin_unloaded so that it cleans after itself when uninstalled or on updating.

Doesn't work on linux

I cloned this repo in the packages directory.

I expect the server to start the installation when I open ST, but that is not happening. (and there is no LSP-pyls folder in the cache folder)

When I open sublime, and open the console I can see that the LSP-pyls plugin loaded, and I expect to see LSP-pyls in this section, but I don't see it:

LSP: global configs ['LSP-dockerfile=True', 'LSP-elm=True', 'LSP-html=True', 'pyls=False', 'LSP-typescript=True', 'LSP-eslint=True', 'LSP-intelephense=True', 'LSP-json=True', 'LSP-css=True', 'lsp-lemminx=True', 'LSP-vue=True', 'ruby=False', 'clangd=True', 'jdtls=False', 'rust-analyzer=False', 'golsp=False', 'elixir-ls=False', 'erlang-ls=False', 'flow=False', 'gopls=False', 'dart=False', 'polymer-ide=False', 'rls=True', 'ocaml=False', 'reason=False', 'sorbet=False', 'sourcekit-lsp=False', 'vscode-css=False', 'haskell-ide-engine=False', 'rlang=False']
ST console output startup, version: 4079 linux x64 channel: dev executable: /opt/sublime_text/sublime_text working dir: /home/predrag packages path: /home/predrag/.config/sublime-text/Packages state path: /home/predrag/.config/sublime-text/Local zip path: /opt/sublime_text/Packages zip path: /home/predrag/.config/sublime-text/Installed Packages ignored_packages: ["ASP", "Batch File", "C#", "Clojure", "Color Scheme - Legacy", "D", "Erlang", "Git Formats", "Go", "Graphviz", "Groovy", "Haskell", "Java", "Language - English", "LaTeX", "Lisp", "Lua", "Makefile", "Matlab", "Objective-C", "OCaml", "Package Syncing", "Pascal", "Perl", "R", "RestructuredText", "ShellScript", "SIDE", "SQL", "TCL", "Textile", "Vintage"] Unable to decode Packages/Theme - Default/common/light/panels_button.png pre session restore time: 0.629832 font face "JetBrains Mono Lighter" could not be found, defaulting to "Monospace" startup time: 0.933405 git: tracking working dir /home/predrag/.config/sublime-text/Packages/LSP-pyls first paint time: 0.989454 reloading plugin Default.arithmetic reloading plugin Default.auto_indent_tag reloading plugin Default.block reloading plugin Default.colors reloading plugin Default.comment reloading plugin Default.convert_color_scheme reloading plugin Default.convert_syntax reloading plugin Default.copy_path reloading plugin Default.echo reloading plugin Default.exec reloading python 3.3 plugin 0_package_control_loader.00-package_control reloading python 3.3 plugin 0_package_control_loader.01-pygments reloading python 3.3 plugin 0_package_control_loader.01-ruamel-yaml reloading python 3.3 plugin 0_package_control_loader.01-sublime_lib reloading python 3.3 plugin 0_package_control_loader.10-lsp_utils reloading python 3.3 plugin 0_package_control_loader.15-coverage reloading python 3.3 plugin 0_package_control_loader.50-markupsafe reloading python 3.3 plugin 0_package_control_loader.50-pymdownx reloading python 3.3 plugin 0_package_control_loader.50-python-markdown reloading plugin Default.fold reloading python 3.3 plugin 0_package_control_loader.50-pyyaml reloading python 3.3 plugin 0_package_control_loader.50-yaml_macros_engine reloading python 3.3 plugin 0_package_control_loader.51-python-jinja2 reloading python 3.3 plugin 0_package_control_loader.55-mdpopups reloading python 3.3 plugin AdvancedNewFile.AdvancedNewFile reloading plugin Default.font reloading plugin Default.goto_line reloading plugin Default.history_list reloading plugin Default.indentation reloading plugin Default.install_package_control reloading python 3.3 plugin ColorHelper.color_helper reloading plugin Default.kill_ring reloading plugin Default.mark reloading plugin Default.new_templates reloading plugin Default.open_context_url reloading plugin Default.open_in_browser reloading plugin Default.pane reloading plugin Default.paragraph reloading plugin Default.paste_from_history reloading plugin Default.profile reloading plugin Default.quick_panel reloading plugin Default.rename reloading plugin Default.run_syntax_tests reloading plugin Default.save_on_focus_lost reloading plugin Default.scroll reloading plugin Default.set_unsaved_view_name reloading plugin Default.settings reloading plugin Default.show_scope_name reloading plugin Default.side_bar reloading plugin Default.sort reloading plugin Default.switch_file reloading plugin Default.symbol reloading plugin Default.transform reloading plugin Default.transpose reloading plugin Default.ui reloading plugin CSS.css_completions reloading plugin Diff.diff reloading plugin HTML.encode_html_entities reloading plugin HTML.html_completions reloading plugin Colored Comments.colored_comments reloading plugin Sass.sass_completions reloading plugin AutomaticPackageReloader.package_reloader reloading plugin UnitTesting.ut reloading python 3.3 plugin ColorHelper.color_helper_insert reloading python 3.3 plugin ColorHelper.color_helper_picker reloading python 3.3 plugin ColorHelper.color_helper_util reloading python 3.3 plugin ColorHelper.multiconf reloading python 3.3 plugin ColorHelper.support reloading python 3.3 plugin DoxyDoxygen (evolution).Doxy reloading python 3.3 plugin Git.git_commands reloading python 3.3 plugin GitDiffView.__init__ reloading python 3.3 plugin GitDiffView.GitDiffView reloading python 3.3 plugin Package Control.1_reloader reloading python 3.3 plugin Package Control.2_bootstrap reloading python 3.3 plugin Package Control.Package Control reloading python 3.3 plugin SnippetMaker.SnippetMaker reloading python 3.3 plugin AutomaticPackageReloader33.package_reloader reloading python 3.3 plugin ColorPicker.sublimecp reloading python 3.3 plugin GithubPR.GithubPR reloading python 3.3 plugin GithubPR.OpenPackage reloading python 3.3 plugin LSP.boot reloading python 3.3 plugin LSP-css.plugin reloading python 3.3 plugin LSP-dockerfile.plugin reloading python 3.3 plugin LSP-elm.plugin reloading python 3.3 plugin LSP-eslint.plugin reloading python 3.3 plugin LSP-html.plugin reloading python 3.3 plugin LSP-intelephense.plugin reloading python 3.3 plugin LSP-json.plugin reloading python 3.3 plugin LSP-lemminx.plugin reloading python 3.3 plugin LSP-pyls.plugin reloading python 3.3 plugin LSP-typescript.plugin reloading python 3.3 plugin LSP-vue.plugin reloading python 3.3 plugin OpenPackage.OpenPackage reloading python 3.3 plugin Terminal.Terminal reloading python 3.3 plugin UnitTesting33.ut plugins loaded LSP-eslint: Installing server LSP: "syntaxes" is deprecated, use "document_selector" instead. The document_selector for ['Packages/PackageDev/Package/Property List/Property List.sublime-syntax', 'Packages/PackageDev/Package/Sublime Text Snippet/Sublime Text Snippet.sublime-syntax', 'Packages/PackageDev/Package/TextMate Preferences/TextMate Preferences.sublime-syntax', 'Packages/XML/XML.sublime-syntax'] was deduced to "text.xml" LSP: "syntaxes" is deprecated, use "document_selector" instead. The document_selector for ['Packages/Python/Python.sublime-syntax'] was deduced to "source.python" LSP: global configs ['LSP-dockerfile=True', 'LSP-elm=True', 'LSP-html=True', 'pyls=False', 'LSP-typescript=True', 'LSP-eslint=True', 'LSP-intelephense=True', 'LSP-json=True', 'LSP-css=True', 'lsp-lemminx=True', 'LSP-vue=True', 'ruby=False', 'clangd=True', 'jdtls=False', 'rust-analyzer=False', 'golsp=False', 'elixir-ls=False', 'erlang-ls=False', 'flow=False', 'gopls=False', 'dart=False', 'polymer-ide=False', 'rls=True', 'ocaml=False', 'reason=False', 'sorbet=False', 'sourcekit-lsp=False', 'vscode-css=False', 'haskell-ide-engine=False', 'rlang=False'] reloading python 3.3 plugin AutomaticPackageReloader33.package_reloader reloading python 3.3 plugin UnitTesting33.ut Package Control: Skipping automatic upgrade, last run at 2020-08-04 19:29:18, next run at 2020-08-04 20:29:18 or after LSP-eslint: Server installed. Sublime Text restart might be required. Unable to find cancel_build command: side_run_task Unable to find cancel_build command: side_run_task
λ  python --version
Python 2.7.17

In order to use ruff: do I need to install ruff manually? If not where is it installed?

I didn't installed ruff, and I don't see it listed by pip3.
But when turned on I'm getting some (not many) complaints about code formatting, like unused variables, too long line etc.
with ruff issue ID like: ruff(F841).
I'm trying to understand what is going on here.
Where is the ruff? How can I configure it (add exemptions, etc...). Or maybe these messages don't come from ruff?

Failed to start LSP-pylsp

It seems that the LSP-pylsp plugin doesn't support pylsp 1.7.3 yet.
version of the plugin: 2.11.1
Please add support for pylsp version 1.7.3

Failed to start LSP-pylsp - disabling for this window for the duration ofthe current session.
Re-enable by running "LSP: Enable Language Server In Project" from theCommand Palette.
--- ErOr ---
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleCollecting mypy==1.3.0
Using cached
https://pypituna.tsinghua.edu.cn/packages/cd/b9/6abe1cd8ac8e70f12f43eebe6427814f9d36142d331eae5cc5bba77585a2/mypy-1.3.0-cp311-cp311win amd64.whl (8.9 MB)
Collecting pyls-isort==0.2.2
Using cached
https://pypi.tunatsinghua.edu.cn/packages/be/61/775e74d8b5e34af59f8c607e7a1584d2a1774f1a1a4af8fc0a96ecc5e499/pyls-isort-0.2.2.tar.gz (2.7KB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'doneCollecting pylsp-mypy==0.6.6
Using cached
https://pypitunatsinghuaedu.cn/packages/6b/da/08322d708bfb4f92a2a468fef31b2c68202cdab795580a65a6969b6f904/pylsp mypy-0.6.6-py3-none-any.whl (10 kB)
Collecting python-lsp-black==1.2.1
Using cached
https://pypitunatsinghua.edu.cn/packages/0a/f4/dbadfbfbd1472569d8c8a8df7a89b8be0c15d3fa20fd635f0cc48467318e/python lsp black-1.2.1-py3-none-any.whl (6.2 kB)
Collecting python-lsp-ruff==1.4.0
Using cached
https://pypituna.tsinghua.edu.cn/packages/31/0c/a692c3fd6c084a1daafea0d922d97f532e1a61d168e482e022340adda35c/python lsp ruff-1.4.0-py3-none-any.whl (9.2 kB)
ERROR: Could not find a version that satisfies the requirementpython-lsp-serverlall]==1.7.3 (from versions: 1.0.0, 1.0.1, 1.1.0, 1.2.0, 1.2.11.2.2, 1.2.3, 1.2.4, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.5.0, 1.6.0, 1.7.0, 1.7.11.7.2)
ERROR: No matching distribution found for python-lsp-serverlall]==1.7.3

the autocompletion does not work on 3rd party packages

for example import can have autocompletion on builtin modules such as time, os, etc. However, it does not work on 3rd party packages at all such as pandas, numpy, lxml, etc. The autocompletion on dot also does not work for those packages. Is the expected?

I did:

pip3 install python-lsp-server[all]

I also installed:

pyls-flake8             0.4.0
pyls-isort              0.2.2
pyls-mypy               0.1.8
pylsp-rope              0.1.8
python-lsp-black        1.0.1

hints for base methods

How do you get doc hints when you hover over a basic method (for example .get, .dict, .copy etc)? I can't get it to work. With methods from imports / self written ones I get the desired popover.

With Pyright I get it correctly:
pyright_hintbubble

My LSP-pylsp.sublime-settings looks like this:

{
    "settings":
    {
        "pylsp.plugins.jedi.environment": "./.venv/"
    }

}


- as I want Pylsp to pick up virtual environment I've set up.
BTW - is there a way to set such things up in some sort of config file in the project, instead of "global" setting in Sublime config? I really like the way it is done in Pyright via pryrightconfig.json .

I've found setup.cfg, but it seems I can set pycodestyle there (for example ignores), but not venv.

MacOS Support

Hello,

While the README doesn't mention MacOS support, I was able to get this working just fine by cloning this repo into my Sublime Packages directory.

Thanks for the nice work on this!

How to use pylsp installed in WSL?

To use pylsp installed in WSL, we can directly set up a client in LSP with command set to ["bash.exe", "-c", "absolute_wsl_path_to_pylsp"].

However, with this helper package LSP-pylsp, if we set command to the above value, it does not work. I suppose that the command in this package just overrides the corresponding key in LSP. How can we use pylsp in WSL with this package?

Renaming plugin is invalid

When I try to modify the function name, after typing the Command Palette LSP:Rename, the status bar prompts that:

Nothing to rename

Before I added the User configuration file, I found the plugin jedi_rename could not be found.

Screen Shot 2022-08-24 at 5 07 07 PM

Format file with black is not working

I'm using Sublime Text 4 with LSP-pylsp on macOS for writing Python code. I use conda environments and have black installed in the environment. However, when I run LSP: Format File in Sublime Text, it does not format the Python file using black. I tried the settings shown below in my .sublime-project file but it doesn't fix my issue.

{
    "python_binary": "/opt/miniconda3/envs/myproj/bin/python",
    "folders":
    [
        {
            "path": "."
        }
    ],
    "settings": {
        "LSP": {
            "LSP-pylsp": {
                "settings": {
                    "pylsp.plugins.jedi.environment": "/opt/miniconda3/envs/myproj"
                }
            }
        }
    }
}

Below are my settings in the LSP-pylsp.sublime-settings file.

{
    "settings": {
        "pylsp.configurationSources": [
            "flake8"
        ],
        "pylsp.plugins.pycodestyle.enabled": false,
        "pylsp.plugins.flake8.enabled": true,
        "pylsp.plugins.flake8.maxLineLength": 120,
        "pylsp.plugins.pylsp_black.enabled": true,
    }
}

flake8 plugins are not operating

I'd like to use bugbear and a few other flake8 plugins within ST4 (4126) on macOS 12.4 21F79 arm64.

LSP, LSP-pylsp, and flake8 seem to be working, and I can get flake8 diagnostics (e.g., line too long) but they don't include plugin diagnostics. Do I need to do something to enable them in my LSP-pylsp.sublime-settings?

// Settings in here override those in "LSP-pylsp/LSP-pylsp.sublime-settings"

{
    "settings":
    {
        "pylsp.plugins.flake8.enabled": true,
        // "pylsp.plugins.flake8.maxLineLength": 88,
        "pylsp.plugins.flake8.perFileIgnores": 
        [
            "emit_biblatex.py:E203,E241,E701,E117,W503",
            "emit_yaml_csl.py:E203,E241,E701,E117,W503",
            "biblio_fields.py:E241"
        ],
        "pylsp.configurationSources": ["flake8"],
        // "pylsp.configurationSources": ["pycodestyle"],
        "pylsp.plugins.pycodestyle.enabled": false,
        "pylsp.plugins.mccabe.enabled": false,
        "pylsp.plugins.pyflakes.enabled": false,
        "pylsp.plugins.pyls_isort.enabled": true,
    }	
}

When formatting, the list will become vertical

It doesn’t matter what formatter I use. I didn’t have this problem when I used pyls before.

settings:

"pylsp": {
            "selector": "source.python",
            "settings": {
                "plugins": {
                    "yapf.enabled": true,
                    "autopep8.enabled": false
                }
            }
        }

yapf config:

[style]
based_on_style = pep8
column_limit = 248

dynamic image:
apngb-animated

yapf is not working?

Formatting a file causes error in LSP log panel

When trying to format a file, nothing happens to the current file. In the LSP log panel, this error appears:

LSP-pylsp: 2022-03-14 20:50:00,152 GMT Standard Time - ERROR - pylsp_jsonrpc.endpoint - Failed to handle request 27
LSP-pylsp: Traceback (most recent call last):
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\endpoint.py", line 116, in consume
LSP-pylsp:     self._handle_request(message['id'], message['method'], message.get('params'))
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\endpoint.py", line 185, in _handle_request
LSP-pylsp:     handler_result = handler(params)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_jsonrpc\dispatchers.py", line 25, in handler
LSP-pylsp:     return method(**(params or {}))
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 366, in m_text_document__formatting
LSP-pylsp:     return self.format_document(textDocument['uri'])
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 281, in format_document
LSP-pylsp:     return self._hook('pylsp_format_document', doc_uri)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp\python_lsp.py", line 156, in _hook
LSP-pylsp:     return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
LSP-pylsp:     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
LSP-pylsp:     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_manager.py", line 327, in traced_hookexec
LSP-pylsp:     return outcome.get_result()
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_result.py", line 60, in get_result
LSP-pylsp:     raise ex[1].with_traceback(ex[2])
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_result.py", line 33, in from_call
LSP-pylsp:     result = func()
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_manager.py", line 324, in <lambda>
LSP-pylsp:     lambda: oldcall(hook_name, hook_impls, kwargs, firstresult)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
LSP-pylsp:     return outcome.get_result()
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_result.py", line 60, in get_result
LSP-pylsp:     raise ex[1].with_traceback(ex[2])
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
LSP-pylsp:     res = hook_impl.function(*args)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_black\plugin.py", line 13, in pylsp_format_document
LSP-pylsp:     return format_document(document)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_black\plugin.py", line 36, in format_document
LSP-pylsp:     config = load_config(document.path)
LSP-pylsp:   File "c:\users\james\appdata\local\sublime text\package storage\lsp-pylsp\lib\site-packages\pylsp_black\plugin.py", line 82, in load_config
LSP-pylsp:     pyproject_filename = root / "pyproject.toml"
LSP-pylsp: TypeError: unsupported operand type(s) for /: 'tuple' and 'str'

In plugin.py line 80, the value of root is (WindowsPath('D:/'), 'file system root'). Looking at Black's documentation, this function is expected to output a tuple - https://black.readthedocs.io/en/stable/contributing/reference/reference_functions.html#black.find_project_root

Unalbe to start subprocess for LSP-pylsp

I'm seeing this message in ST4 console that's somewhat mysterious:

Unable to start subprocess for LSP-pylsp
Traceback (most recent call last):
  File "C:\Users\mchan811\AppData\Roaming\Sublime Text\Installed Packages\LSP.sublime-package\plugin/core/windows.py", line 241, in start_async
    plugin_class.install_or_update()
  File "C:\Users\mchan811\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\_client_handler\abstract_plugin.py", line 109, in install_or_update
    server.install_or_update()
  File "C:\Users\mchan811\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\server_pip_resource.py", line 97, in install_or_update
    self.run(self._python_binary, '-m', 'venv', self._package_name, cwd=self._storage_path)
  File "C:\Users\mchan811\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\server_pip_resource.py", line 35, in run
    raise Exception(error)
Exception: Error: [WinError 2] The system cannot find the file specified

I tried reinstalling both LSP-pylsp and the LSP package to no avail. Any suggestions?

Performance Questions

Performance for showing the completion menu is VERY slow (takes over 3 seconds to appear for a 150-line Python script even for primitive types like str). Confirmed that this happens on two different machines: gen 10 i7s with 16GB and 64GB of RAM respectively so hardware isn't the bottleneck.

  1. Does anyone else see slowdowns to this degree?
  2. Are there any settings I can disable to improve performance?
  3. Is there a way to profile/trace to see where in the stack the slowdown is happening?

Versions

Fedora 35
Sublime v 4126
Python v3.10.4
LSP v1.16.2
LSP-pylsp v2.3.3

Configs

LSP-pylsp.sublime-settings

{
    "settings": {
        "pylsp.plugins.pyflakes.enabled": false,
        "pylsp.plugins.pylsp_mypy.enabled": false,
        "pylsp.plugins.mccabe.enabled": false,
        "pylsp.plugins.preload.enabled": false,

        "pylsp.plugins.pycodestyle.enabled": false,
        "pylsp.plugins.pycodestyle.ignore": [
            "E221",
            "E241",
            "E501",
            "W504",
        ],
    }
}

LSP.sublime-settings

{
    "document_highlight_style": "fill",
}

Finally, thanks for your work. This thing does almost everything I need it to, just unbearably slowly...

Autocompletions not being found for numpy

I have installed LSP-pylsp on ST4 and generally everything is working well.
Only problem I have is that it isn't providing me with any autocompletions for numpy.

I have everything in a venv and am pretty sure I'm pointing to the right location with the following in a .sublime-project file:

"settings": {
    "LSP": {
        "LSP-pylsp": {
            "command": [
                "/Path/To/venv/my_venv/bin/pylsp",
            ],
            "settings": {
   	        // Jedi config
   	        "pylsp.plugins.jedi.environment": "/Path/To/venv/my_venv",
   	        // Linter config:
   	        "pylsp.plugins.pycodestyle.enabled": false,
   	        "pylsp.plugins.flake8.enabled": true,
   	        "pylsp.configurationSources": ["flake8"],
   	        // formatter config
   	        "pylsp.plugins.autopep8.enabled": false,
   	        "pylsp.plugins.pylsp_black.enabled": true,
   	        "pylsp.plugins.pylsp_black.cache_config": true,
   	        "pylsp.plugins.pylsp_black.line_length": 88,
   	        "pylsp.plugins.pylsp_black.preview": true,
            },
        },
    },
},

Generally I am getting autocompletion.
If I start typing import it suggests modules in my venv:
image
image

It then suggests autocompletions for functions in that module:
image

However, this is not working for numpy.
It detects numpy in my venv when I come to import it (see image above), but does not provide any numpy autocompletion when using it:
image

If you can work out what's going wrong I'd be really grateful, and apologies if I've missed something somewhere - I've been battling with setting this up all afternoon. Thanks.

Cannot disable mypy

Summary

Eventhough mypy disabled in LSP-pylsp preference, but mypy still reproduce cache file and check for errors

Expected Results

mypy disabled if configured so in LSP-pylsp preference

Details

I have explicitly configured so that mypy disabled:

// Settings in here override those in "LSP-pylsp/LSP-pylsp.sublime-settings"
{
  "settings": {
    "pylsp.env": {
      "PYTHONPATH": "$sublime_py_files_dir:$packages",
      // "MYPY_PATH": "$sublime_py_files_dir:$packages"
    },
    "pylsp.plugins.mypy-ls.enabled": false,
    "pylsp.plugins.mypy-ls.live_mode": false,
  },
}

but when I open any Python files, it still reproduce .mypy.cache file and still show mypy errors

Screenshot of LSP-pylsp mypy error

FileNotFoundError

Hello,

I can't find a way to run LSP-pylsp after installing the package I get this error :

FileNotFoundError: [Errno 2] No such file or directory: '~/.cache/sublime-text-3/Package Storage/LSP-pylsp/bin/pip'

I have tried creating the folder and restart but it looks like something is removing it.

Can anyone help me to figure this out ?

P.S. : I have LSP-pyright running perfectly

EDIT : Adding the traceback :

Traceback (most recent call last):
  File "~/.config/sublime-text-3/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 245, in start_async
    plugin_class.install_or_update()
  File "~/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/_client_handler/abstract_plugin.py", line 109, in install_or_update
    server.install_or_update()
  File "~/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/server_pip_resource.py", line 100, in install_or_update
    self.run(self.pip_binary(), 'install', '-r', dest_requirements_txt_path, '--disable-pip-version-check')
  File "~/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/server_pip_resource.py", line 33, in run
    output, error = run_command_sync(list(args), cwd=cwd)
  File "~/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/helpers.py", line 40, in run_command_sync
    args, cwd=cwd, shell=shell, stderr=subprocess.STDOUT, env=env, startupinfo=startupinfo)
  File "./python3.3/subprocess.py", line 576, in check_output
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1452, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: '~/.cache/sublime-text-3/Package Storage/LSP-pylsp/bin/pip'

Allow to choose a different pylsp executable

As in title, I would like to be able to use pylsp executable that I have globally installed in my system rather than rely on the one installed in a venv created by LSP-pylsp.

This would allow pylsp plugins to be able to see and use the additional dependencies like mypy plugins, type stubs, and regular python packages that are needed for static analysis.

LSP-pylsp server has crashed

Hi, im starting to learn python and decided to try this for sublime text 4, but im having a crash server.
Here's what i did.

winget install -e --id SublimeHQ.SublimeText.4
winget install -e --id Python.Python.3.11
pip install python-lsp-server[all]

Restart pc and open sublime text 4.
inside sublime text 4, i install LSP and LSP-pylsp

but when i open sublime and open .py file it crashes.

Troubleshooting: LSP-pylsp

Version

  • LSP: 1.21.0
  • Sublime Text: 4143

Server Test Run

  • exit code: 1
  • output
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\hoaxdream\AppData\Local\Sublime Text\Package Storage\LSP-pylsp\Scripts\pylsp.exe\__main__.py", line 4, in <module>
  File "C:\Users\hoaxdream\AppData\Local\Sublime Text\Package Storage\LSP-pylsp\Lib\site-packages\pylsp\__main__.py", line 15, in <module>
    from .python_lsp import (PythonLSPServer, start_io_lang_server,
  File "C:\Users\hoaxdream\AppData\Local\Sublime Text\Package Storage\LSP-pylsp\Lib\site-packages\pylsp\python_lsp.py", line 9, in <module>
    import ujson as json
ImportError: DLL load failed while importing ujson: The specified module could not be found.

Server Configuration

  • command
[
  "$server_path"
]
  • shell command
"C:\Users\hoaxdream\AppData\Local\Sublime Text\Package Storage\LSP-pylsp\Scripts\pylsp.exe"
  • selector
source.python
  • priority_selector
(source.python)
  • init_options
{}
  • settings
{
  "pylsp": {
    "configurationSources": [
      "pycodestyle"
    ], 
    "plugins": {
      "autopep8": {
        "enabled": true
      }, 
      "flake8": {
        "config": null, 
        "enabled": false, 
        "exclude": null, 
        "executable": "flake8", 
        "filename": null, 
        "hangClosing": null, 
        "ignore": null, 
        "maxComplexity": null, 
        "maxLineLength": null, 
        "perFileIgnores": null, 
        "select": null
      }, 
      "jedi": {
        "auto_import_modules": [
          "numpy"
        ], 
        "env_vars": null, 
        "environment": null, 
        "extra_paths": [
          "$sublime_py_files_dir", 
          "$packages"
        ]
      }, 
      "jedi_completion": {
        "cache_for": [
          "pandas", 
          "numpy", 
          "tensorflow", 
          "matplotlib"
        ], 
        "eager": false, 
        "enabled": true, 
        "fuzzy": true, 
        "include_class_objects": false, 
        "include_function_objects": false, 
        "include_params": true, 
        "resolve_at_most": 25
      }, 
      "jedi_definition": {
        "enabled": true, 
        "follow_builtin_definitions": true, 
        "follow_builtin_imports": true, 
        "follow_imports": true
      }, 
      "jedi_hover": {
        "enabled": true
      }, 
      "jedi_references": {
        "enabled": true
      }, 
      "jedi_signature_help": {
        "enabled": true
      }, 
      "jedi_symbols": {
        "all_scopes": true, 
        "enabled": true, 
        "include_import_symbols": true
      }, 
      "mccabe": {
        "enabled": true, 
        "threshold": 15
      }, 
      "preload": {
        "enabled": true, 
        "modules": null
      }, 
      "pycodestyle": {
        "aggressive": null, 
        "enabled": true, 
        "exclude": null, 
        "filename": null, 
        "hangClosing": null, 
        "ignore": null, 
        "maxLineLength": null, 
        "select": null
      }, 
      "pydocstyle": {
        "addIgnore": null, 
        "addSelect": null, 
        "convention": null, 
        "enabled": false, 
        "ignore": null, 
        "match": "(?!test_).*\\.py", 
        "matchDir": "[^\\.].*", 
        "select": null
      }, 
      "pyflakes": {
        "enabled": false
      }, 
      "pylint": {
        "args": null, 
        "enabled": false, 
        "executable": ""
      }, 
      "pyls_isort": {
        "enabled": false
      }, 
      "pylsp_black": {
        "cache_config": false, 
        "enabled": false, 
        "line_length": 88, 
        "preview": false
      }, 
      "pylsp_mypy": {
        "config_sub_paths": [], 
        "dmypy": false, 
        "dmypy_status_file": ".dmypy.json", 
        "enabled": false, 
        "live_mode": true, 
        "overrides": [
          true
        ], 
        "report_progress": false, 
        "strict": false
      }, 
      "rope_autoimport": {
        "enabled": false, 
        "memory": false
      }, 
      "rope_completion": {
        "eager": false, 
        "enabled": false
      }, 
      "yapf": {
        "enabled": false
      }
    }, 
    "rope": {
      "extensionModules": null, 
      "ropeFolder": null
    }
  }
}
  • env
{
  "MYPYPATH": "${sublime_py_files_dir}${pathsep}${packages}", 
  "PATH": "C:\\Users\\hoaxdream\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pylsp\\Scripts;C:\\Users\\hoaxdream\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pylsp\\Scripts;C:\\Users\\hoaxdream\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pylsp\\Scripts;C:\\Users\\hoaxdream\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pylsp\\Scripts;C:\\Users\\hoaxdream\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pylsp\\Scripts;C:\\Users\\hoaxdream\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-pylsp\\Scripts;", 
  "PYTHONPATH": "${sublime_py_files_dir}${pathsep}${packages}"
}

Active view

  • File name
C:\Users\hoaxdream\Desktop\src\pythonproj\test.py
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", 
  "lsp_active": null, 
  "syntax": "Packages/Python/Python.sublime-syntax"
}
  • base scope
source.python

Project / Workspace

  • folders
[
  "C:\\Users\\hoaxdream\\Desktop\\src\\pythonproj"
]
  • is project: False

LSP configuration

{}

System PATH

  • C:\Program Files\ImageMagick-7.1.0-Q16-HDRI
  • C:\Windows\system32
  • C:\Windows
  • C:\Windows\System32\Wbem
  • C:\Windows\System32\WindowsPowerShell\v1.0\
  • C:\Windows\System32\OpenSSH\
  • C:\Program Files\Git\cmd
  • C:\Program Files\nodejs\
  • C:\Program Files\MiKTeX\miktex\bin\x64\
  • C:\Users\hoaxdream\scoop\apps\mpv-git\current
  • C:\Users\hoaxdream\scoop\shims
  • C:\Users\hoaxdream\AppData\Local\Programs\Python\Python311\Scripts\
  • C:\Users\hoaxdream\AppData\Local\Programs\Python\Python311\
  • C:\Users\hoaxdream\AppData\Local\Microsoft\WindowsApps
  • C:\Users\hoaxdream\AppData\Roaming\npm
  • C:\Users\hoaxdream\AppData\Local\Pandoc\
  • C:\Users\hoaxdream\AppData\Local\Microsoft\WinGet\Links

typed-ast version mismatch

Hello, I'm getting this message from LSP-pylsp
pkg_resources.ContextualVersionConflict: (typed-ast 1.5.0 (/home/julian/.cache/sublime-text-3/Package Storage/LSP-pylsp/lib/python3.7/site-packages), Requirement.parse('typed-ast<1.5.0,>=1.4.0;python_version < "3.8"'),{'mypy'})

I tried upgrading mypy on my system (as local user and sudo) it didn't help.
I'm trying to downgrade typed-ast now

Option to input a proxy server?

Hello,

Is there a method to use a proxy in order to download the required Python packages during installation? I'm behind a corporate firewall and can't download from external sources without a proxy bypass.

pyls exited with status code -32602

I'm using ST4(4101) on macOS 11.2.3.
My project settings:

{
	"folders": [
		{
			"path": ".",
		}
	],
	"settings": {
		"LSP": {
			"pyls": {
				"enabled": true,
				"env": {
					"PYTHONPATH": "/Users/thepoy/venvs/spider/lib/python3.8/site-packages",
				},
				"command": [
					"/Users/thepoy/Library/Python/3.8/bin/pyls"
				],
			},
		},
	},
}

pyls can't work.
The log in console:

Traceback (most recent call last):
  File "/Users/thepoy/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/transports.py", line 137, in invoke
  File "/Users/thepoy/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/sessions.py", line 1259, in on_transport_close
  File "/Users/thepoy/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 433, in on_post_exit_async
  File "./python3.3/_weakrefset.py", line 60, in __iter__
RuntimeError: Set changed size during iteration

why flake8 doesn't work?

Here is my pylsp configuration:

{
    "pylsp.configurationSources": ["flake8"],
    "pylsp.plugins.flake8.enabled": true,
    "pylsp.plugins.pycodestyle.enabled": false,
}

And I try to restart sublime several times, however, it just doesn't work and linter is stiil pycodestyle.

But, what is strange is that the option "python-binary" can work when I rewrite it. So, I think the user configuration on linter written by user seems to be unable to cover the defualt.

LSP won't load in sublimetext 4121

I'm seeing this message in the console

Traceback (most recent call last):
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 308, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1692, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "/home/julian/.config/sublime-text-3/Installed Packages/LSP-pylsp.sublime-package/plugin.py", line 1, in <module>
ImportError: No module named 'LSP'

My machine is linux mint debian edition LMDE4

I don't know anything about how ST loads packages, but nothing else is creating an error
.config/sublime-text-3/Installed Packages/LSP-pylsp.sublime-package/plugin.py
is not a file
.config/sublime-text-3/Installed Packages/LSP-pylsp.sublime-package
is an archive with plugin.py in it.

Thanks

Crashes after updating Python

I've set up this package a week or so ago and it created a cached directory with pyvenv.cfg with version = 3.7.7.
I have later updated python to 3.8.3 through brew and then this package started crashing on this line:
https://github.com/sublimelsp/LSP-pyls/blob/2909522a310dbb665acead21a988eb68469b4074/plugin.py#L74
with a stderr:

Traceback (most recent call last):
  File "/Users/me/Library/Application Support/Sublime Text/Cache/LSP-pyls/bin/pip", line 8, in <module>
    from pip._internal import main
ModuleNotFoundError: No module named 'pip'

Deleting the Cache/LSP-pyls directory helped as that recreated the virtual environment using latest Python.

I would probably suggest catching errors in needs_update_or_installation and return True in such a case so that the cache is recreated and handles such issues automatically.

Cannot use a python version installed from source

Hi! I'm under Linux Mint 21 Vanessa (based on Ubuntu 22.04 jammy) where the python3 command points to the system python 3.10 version. In order to preserve that version for the system and use python 3.11 for development, I've installed separately python 3.11 from source. Now I have python3 and python3.11 in my PATH. Can I point LSP-pylsp to use the python3.11 command? By default it takes python3... I cannot figure out how to do it. Thank you!

Using python from conda installation

Is there any way to use this with conda on windows 10? I cannot figure out how to properly configure the python path so that the server can start.
Currently I get an error message:

Failed to start LSP-pylsp - disabling for this window for the duration of
the current session.
Re-enable by running "LSP: Enable Language Sever In Project" from the command palette.

--- Error: ---
'python' is not recognized as an internal or external command,
operable program of batch file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.