diff --git a/external-deps/python-lsp-server/.gitrepo b/external-deps/python-lsp-server/.gitrepo index 3df24fa3919..7fbea2bf097 100644 --- a/external-deps/python-lsp-server/.gitrepo +++ b/external-deps/python-lsp-server/.gitrepo @@ -4,9 +4,9 @@ ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme ; [subrepo] - remote = https://github.com/python-lsp/python-lsp-server.git - branch = develop - commit = 5a383df418d2800b5abc5dd3a43b3061026fda07 - parent = 71e053bf7d815c0176974f9c9d5031b64946a8d9 + remote = /Users/rclary/Documents/Repos/python-lsp-server + branch = ppm-syspath + commit = 12aafe6c8bc02d19d326f012b4405fd652b44438 + parent = 5d3aa087c3590fc3db9a48e5bb942af1d5a4babc method = merge - cmdver = 0.4.3 + cmdver = 0.4.6 diff --git a/external-deps/python-lsp-server/CONFIGURATION.md b/external-deps/python-lsp-server/CONFIGURATION.md index acf8a85fb40..bd746f767de 100644 --- a/external-deps/python-lsp-server/CONFIGURATION.md +++ b/external-deps/python-lsp-server/CONFIGURATION.md @@ -20,6 +20,7 @@ This server can be configured using the `workspace/didChangeConfiguration` metho | `pylsp.plugins.flake8.select` | `array` of unique `string` items | List of errors and warnings to enable. | `null` | | `pylsp.plugins.jedi.auto_import_modules` | `array` of `string` items | List of module names for jedi.settings.auto_import_modules. | `["numpy"]` | | `pylsp.plugins.jedi.extra_paths` | `array` of `string` items | Define extra paths for jedi.Script. | `[]` | +| `pylsp.plugins.jedi.prioritize` | `boolean` | Whether to place extra_paths at the beginning (true) or end (false) of `sys.path` | `false` | | `pylsp.plugins.jedi.env_vars` | `object` | Define environment variables for jedi.Script and Jedi.names. | `null` | | `pylsp.plugins.jedi.environment` | `string` | Define environment for jedi.Script and Jedi.names. | `null` | | `pylsp.plugins.jedi_completion.enabled` | `boolean` | Enable or disable the plugin. | `true` | diff --git a/external-deps/python-lsp-server/pylsp/config/schema.json b/external-deps/python-lsp-server/pylsp/config/schema.json index ba1d36f8fc8..43b87e3c17d 100644 --- a/external-deps/python-lsp-server/pylsp/config/schema.json +++ b/external-deps/python-lsp-server/pylsp/config/schema.json @@ -143,6 +143,11 @@ }, "description": "Define extra paths for jedi.Script." }, + "pylsp.plugins.jedi.prioritize": { + "type": "boolean", + "default": false, + "description": "Whether to place extra_paths at the beginning (true) or end (false) of `sys.path`" + }, "pylsp.plugins.jedi.env_vars": { "type": [ "object", @@ -500,4 +505,4 @@ "description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all." } } -} \ No newline at end of file +} diff --git a/external-deps/python-lsp-server/pylsp/python_lsp.py b/external-deps/python-lsp-server/pylsp/python_lsp.py index a3f737ac373..c606a7c6fa7 100644 --- a/external-deps/python-lsp-server/pylsp/python_lsp.py +++ b/external-deps/python-lsp-server/pylsp/python_lsp.py @@ -109,7 +109,7 @@ def start_ws_lang_server(port, check_parent_process, handler_class): import websockets except ImportError as e: raise ImportError( - "websocket modules missing. Please run pip install 'python-lsp-server[websockets]" + "websocket modules missing. Please run: pip install 'python-lsp-server[websockets]'" ) from e with ThreadPoolExecutor(max_workers=10) as tpool: diff --git a/external-deps/python-lsp-server/pylsp/workspace.py b/external-deps/python-lsp-server/pylsp/workspace.py index c1b32f20d72..0ad8fff0cf3 100644 --- a/external-deps/python-lsp-server/pylsp/workspace.py +++ b/external-deps/python-lsp-server/pylsp/workspace.py @@ -507,6 +507,7 @@ def jedi_script(self, position=None, use_document_path=False): extra_paths = [] environment_path = None env_vars = None + prioritize = False if self._config: jedi_settings = self._config.plugin_settings( @@ -523,19 +524,18 @@ def jedi_script(self, position=None, use_document_path=False): extra_paths = jedi_settings.get("extra_paths") or [] env_vars = jedi_settings.get("env_vars") + prioritize = jedi_settings.get("prioritize") - # Drop PYTHONPATH from env_vars before creating the environment because that makes - # Jedi throw an error. + # Drop PYTHONPATH from env_vars before creating the environment to + # ensure that Jedi can startup properly without module name collision. if env_vars is None: env_vars = os.environ.copy() env_vars.pop("PYTHONPATH", None) - environment = ( - self.get_enviroment(environment_path, env_vars=env_vars) - if environment_path - else None - ) - sys_path = self.sys_path(environment_path, env_vars=env_vars) + extra_paths + environment = self.get_enviroment(environment_path, env_vars=env_vars) + + sys_path = self.sys_path(environment_path, env_vars, prioritize, extra_paths) + project_path = self._workspace.root_path # Extend sys_path with document's path if requested @@ -545,7 +545,7 @@ def jedi_script(self, position=None, use_document_path=False): kwargs = { "code": self.source, "path": self.path, - "environment": environment, + "environment": environment if environment_path else None, "project": jedi.Project(path=project_path, sys_path=sys_path), } @@ -570,14 +570,18 @@ def get_enviroment(self, environment_path=None, env_vars=None): return environment - def sys_path(self, environment_path=None, env_vars=None): + def sys_path(self, environment_path=None, env_vars=None, prioritize=False, extra_paths=[]): # Copy our extra sys path - # TODO: when safe to break API, use env_vars explicitly to pass to create_environment path = list(self._extra_sys_path) environment = self.get_enviroment( environment_path=environment_path, env_vars=env_vars ) path.extend(environment.get_sys_path()) + if prioritize: + path += extra_paths + path + else: + path += path + extra_paths + return path