Skip to content

Commit

Permalink
[ci-skip] Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
  • Loading branch information
mrclary and ccordoba12 committed May 18, 2024
1 parent e32005e commit 3706a34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +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.prioritize_extra_paths` | `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` |
Expand Down
2 changes: 1 addition & 1 deletion pylsp/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
},
"description": "Define extra paths for jedi.Script."
},
"pylsp.plugins.jedi.prioritize": {
"pylsp.plugins.jedi.prioritize_extra_paths": {
"type": "boolean",
"default": false,
"description": "Whether to place extra_paths at the beginning (true) or end (false) of `sys.path`"
Expand Down
9 changes: 4 additions & 5 deletions pylsp/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def jedi_script(self, position=None, use_document_path=False):
extra_paths = []
environment_path = None
env_vars = None
prioritize = False
prioritize_extra_paths = False

if self._config:
jedi_settings = self._config.plugin_settings(
Expand All @@ -533,8 +533,7 @@ def jedi_script(self, position=None, use_document_path=False):
env_vars.pop("PYTHONPATH", None)

environment = self.get_enviroment(environment_path, env_vars=env_vars)

sys_path = self.sys_path(environment_path, env_vars, prioritize, extra_paths)
sys_path = self.sys_path(environment_path, env_vars, prioritize_extra_paths, extra_paths)

project_path = self._workspace.root_path

Expand Down Expand Up @@ -571,15 +570,15 @@ def get_enviroment(self, environment_path=None, env_vars=None):
return environment

def sys_path(
self, environment_path=None, env_vars=None, prioritize=False, extra_paths=[]
self, environment_path=None, env_vars=None, prioritize_extra_paths=False, extra_paths=[]
):
# Copy our extra sys path
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:
if prioritize_extra_paths:
path += extra_paths + path
else:
path += path + extra_paths
Expand Down

0 comments on commit 3706a34

Please sign in to comment.