Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Use completionItem/resolve to improve completion performance #16057

Merged
merged 3 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion external-deps/python-lsp-server/.github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ jobs:
# errors first
python-version: '3.6'
architecture: 'x64'
- run: python -m pip install --upgrade pip setuptools
- run: python -m pip install --upgrade pip setuptools jsonschema
- run: pip install -e .[pylint,pycodestyle,pyflakes]
- name: Pylint checks
run: pylint pylsp test
- name: Code style checks
run: pycodestyle pylsp test
- name: Pyflakes checks
run: pyflakes pylsp test
- name: Validate JSON schema
run: jsonschema pylsp/config/schema.json
- name: Ensure JSON schema and Markdown docs are in sync
run: |
python scripts/jsonschema2md.py pylsp/config/schema.json EXPECTED_CONFIGURATION.md
diff EXPECTED_CONFIGURATION.md CONFIGURATION.md
3 changes: 3 additions & 0 deletions external-deps/python-lsp-server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ __pycache__/
*.py[cod]
*$py.class

# Mypy cache
.mypy_cache/

# IntelliJ
*.iml
*.ipr
Expand Down
4 changes: 2 additions & 2 deletions external-deps/python-lsp-server/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/python-lsp/python-lsp-server.git
branch = develop
commit = 22a746e5e1dc1c075360242cfd27813687f1b142
parent = 04e393bcea8ee2968bab4ff9a861300c3f802b20
commit = 58b229b520b7cb78196115d0366e94596242dc4c
parent = f8e5f56cc0515580006c349ebe4fe7e16b411284
method = merge
cmdver = 0.4.3
30 changes: 30 additions & 0 deletions external-deps/python-lsp-server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## Version 1.1.0 (2021-06-25)

### New features

* Add support for flake8 per-file-ignores
* Add --version CLI argument and return version in InitializeResult

### Issues Closed

* [Issue 30](https://github.com/python-lsp/python-lsp-server/issues/30) - pylsp_document_symbols raising TypeError from os.path.samefile ([PR 31](https://github.com/python-lsp/python-lsp-server/pull/31) by [@douglasdavis](https://github.com/douglasdavis))
* [Issue 19](https://github.com/python-lsp/python-lsp-server/issues/19) - Linter and tests are failing on due to new "consider-using-with" ([PR 20](https://github.com/python-lsp/python-lsp-server/pull/20) by [@krassowski](https://github.com/krassowski))

In this release 2 issues were closed.

### Pull Requests Merged

* [PR 44](https://github.com/python-lsp/python-lsp-server/pull/44) - Add --version CLI argument and return version in InitializeResult, by [@nemethf](https://github.com/nemethf)
* [PR 42](https://github.com/python-lsp/python-lsp-server/pull/42) - Fix local timezone, by [@e-kwsm](https://github.com/e-kwsm)
* [PR 38](https://github.com/python-lsp/python-lsp-server/pull/38) - Handling list merge in _utils.merge_dicts()., by [@GaetanLepage](https://github.com/GaetanLepage)
* [PR 32](https://github.com/python-lsp/python-lsp-server/pull/32) - PR: Update third-party plugins in README, by [@haplo](https://github.com/haplo)
* [PR 31](https://github.com/python-lsp/python-lsp-server/pull/31) - Catch a TypeError from os.path.samefile, by [@douglasdavis](https://github.com/douglasdavis) ([30](https://github.com/python-lsp/python-lsp-server/issues/30))
* [PR 28](https://github.com/python-lsp/python-lsp-server/pull/28) - Add support for flake8 per-file-ignores, by [@brandonwillard](https://github.com/brandonwillard)
* [PR 20](https://github.com/python-lsp/python-lsp-server/pull/20) - PR: Address pylint's "consider-using-with" warnings, by [@krassowski](https://github.com/krassowski) ([19](https://github.com/python-lsp/python-lsp-server/issues/19))
* [PR 18](https://github.com/python-lsp/python-lsp-server/pull/18) - Fix Jedi type map (use types offered by modern Jedi), by [@krassowski](https://github.com/krassowski)

In this release 8 pull requests were closed.

----

## Version 1.0.1 (2021-04-22)

### Issues Closed
Expand All @@ -13,6 +42,7 @@ In this release 1 issue was closed.

In this release 2 pull requests were closed.

----

## Version 1.0.0 (2021/04/14)

Expand Down
54 changes: 54 additions & 0 deletions external-deps/python-lsp-server/CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Python Language Server Configuration
This server can be configured using `workspace/didChangeConfiguration` method. Each configuration option is described below:

| **Configuration Key** | **Type** | **Description** | **Default**
|----|----|----|----|
| `pylsp.configurationSources` | `array` of unique `string` items | List of configuration sources to use. | `["pycodestyle"]` |
| `pylsp.plugins.jedi.extra_paths` | `array` | Define extra paths for jedi.Script. | `[]` |
| `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` |
| `pylsp.plugins.jedi_completion.include_params` | `boolean` | Auto-completes methods and classes with tabstops for each parameter. | `true` |
| `pylsp.plugins.jedi_completion.include_class_objects` | `boolean` | Adds class objects as a separate completion item. | `true` |
| `pylsp.plugins.jedi_completion.fuzzy` | `boolean` | Enable fuzzy when requesting autocomplete. | `false` |
| `pylsp.plugins.jedi_completion.eager` | `boolean` | Resolve documentation and detail eagerly. | `false` |
| `pylsp.plugins.jedi_completion.resolve_at_most_labels` | `number` | How many labels (at most) should be resolved? | `25` |
| `pylsp.plugins.jedi_completion.cache_labels_for` | `array` of `string` items | Modules for which the labels should be cached. | `["pandas", "numpy", "tensorflow", "matplotlib"]` |
| `pylsp.plugins.jedi_definition.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.jedi_definition.follow_imports` | `boolean` | The goto call will follow imports. | `true` |
| `pylsp.plugins.jedi_definition.follow_builtin_imports` | `boolean` | If follow_imports is True will decide if it follow builtin imports. | `true` |
| `pylsp.plugins.jedi_hover.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.jedi_references.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.jedi_signature_help.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.jedi_symbols.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.jedi_symbols.all_scopes` | `boolean` | If True lists the names of all scopes instead of only the module namespace. | `true` |
| `pylsp.plugins.mccabe.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.mccabe.threshold` | `number` | The minimum threshold that triggers warnings about cyclomatic complexity. | `15` |
| `pylsp.plugins.preload.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.preload.modules` | `array` of unique `string` items | List of modules to import on startup | `null` |
| `pylsp.plugins.pycodestyle.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.pycodestyle.exclude` | `array` of unique `string` items | Exclude files or directories which match these patterns. | `null` |
| `pylsp.plugins.pycodestyle.filename` | `array` of unique `string` items | When parsing directories, only check filenames matching these patterns. | `null` |
| `pylsp.plugins.pycodestyle.select` | `array` of unique `string` items | Select errors and warnings | `null` |
| `pylsp.plugins.pycodestyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `null` |
| `pylsp.plugins.pycodestyle.hangClosing` | `boolean` | Hang closing bracket instead of matching indentation of opening bracket's line. | `null` |
| `pylsp.plugins.pycodestyle.maxLineLength` | `number` | Set maximum allowed line length. | `null` |
| `pylsp.plugins.pydocstyle.enabled` | `boolean` | Enable or disable the plugin. | `false` |
| `pylsp.plugins.pydocstyle.convention` | `string` | Choose the basic list of checked errors by specifying an existing convention. | `null` |
| `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the specified convention. | `null` |
| `pylsp.plugins.pydocstyle.addSelect` | `array` of unique `string` items | Select errors and warnings in addition to the specified convention. | `null` |
| `pylsp.plugins.pydocstyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `null` |
| `pylsp.plugins.pydocstyle.select` | `array` of unique `string` items | Select errors and warnings | `null` |
| `pylsp.plugins.pydocstyle.match` | `string` | Check only files that exactly match the given regular expression; default is to match files that don't start with 'test_' but end with '.py'. | `"(?!test_).*\\.py"` |
| `pylsp.plugins.pydocstyle.matchDir` | `string` | Search only dirs that exactly match the given regular expression; default is to match dirs which do not begin with a dot. | `"[^\\.].*"` |
| `pylsp.plugins.pyflakes.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.pylint.enabled` | `boolean` | Enable or disable the plugin. | `false` |
| `pylsp.plugins.pylint.args` | `array` of non-unique `string` items | Arguments to pass to pylint. | `null` |
| `pylsp.plugins.pylint.executable` | `string` | Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3. | `null` |
| `pylsp.plugins.rope_completion.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.plugins.rope_completion.eager` | `boolean` | Resolve documentation and detail eagerly. | `false` |
| `pylsp.plugins.yapf.enabled` | `boolean` | Enable or disable the plugin. | `true` |
| `pylsp.rope.extensionModules` | `string` | Builtin and c-extension modules that are allowed to be imported and inspected by rope. | `null` |
| `pylsp.rope.ropeFolder` | `array` of unique `string` items | The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all. | `null` |

This documentation was generated from `pylsp/config/schema.json`. Please do not edit this file directly.
25 changes: 17 additions & 8 deletions external-deps/python-lsp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ pip install -U setuptools

Installing these plugins will add extra functionality to the language server:

- [pyls-mypy](https://github.com/tomv564/pyls-mypy) Mypy type checking for Python 3
- [pyls-isort](https://github.com/paradoxxxzero/pyls-isort) Isort import sort code formatting
- [pyls-black](https://github.com/rupert/pyls-black) for code formatting using [Black](https://github.com/ambv/black)
- [pyls-memestra](https://github.com/QuantStack/pyls-memestra) for detecting the use of deprecated APIs
- [pyls-flake8](https://github.com/emanspeaks/pyls-flake8/): Error checking using [flake8](https://flake8.pycqa.org/en/latest/).
- [mypy-ls](https://github.com/Richardk2n/mypy-ls): [MyPy](http://mypy-lang.org/) type checking for Python 3.
- [pyls-isort](https://github.com/paradoxxxzero/pyls-isort): code formatting using [isort](https://github.com/PyCQA/isort) (automatic import sorting).
- [python-lsp-black](https://github.com/python-lsp/python-lsp-black): code formatting using [Black](https://github.com/psf/black).
- [pyls-memestra](https://github.com/QuantStack/pyls-memestra): detecting the use of deprecated APIs.

Please see the above repositories for examples on how to write plugins for the Python Language Server. Please file an issue if you require assistance writing a plugin.
Please see the above repositories for examples on how to write plugins for the Python LSP Server. Please file an issue if you require assistance writing a plugin.

## Configuration

Expand All @@ -59,12 +60,14 @@ Configuration is loaded from zero or more configuration sources. Currently impl

The default configuration source is pycodestyle. Change the `pylsp.configurationSources` setting to `['flake8']` in order to respect flake8 configuration instead.

Overall configuration is computed first from user configuration (in home directory), overridden by configuration passed in by the language client, and then overriden by configuration discovered in the workspace.
Overall configuration is computed first from user configuration (in home directory), overridden by configuration passed in by the language client, and then overridden by configuration discovered in the workspace.

To enable pydocstyle for linting docstrings add the following setting in your LSP configuration:
`"pylsp.plugins.pydocstyle.enabled": true`

## Language Server Features
All configuration options are described in [`CONFIGURATION.md`](https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md).

## LSP Server Features

* Auto Completion
* Code Linting
Expand All @@ -81,8 +84,14 @@ To enable pydocstyle for linting docstrings add the following setting in your LS

To run the test suite:

```sh
pip install '.[test]' && pytest
```

After adding configuration options to `schema.json`, refresh the `CONFIGURATION.md` file with

```
pip install .[test] && pytest
python scripts/jsonschema2md.py pylsp/config/schema.json CONFIGURATION.md
```

## License
Expand Down
12 changes: 6 additions & 6 deletions external-deps/python-lsp-server/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ To release a new version of python-lsp-server:
1. git fetch upstream && git checkout upstream/master
2. Close milestone on GitHub
3. git clean -xfdi
4. Update CHANGELOG.md with loghub
4. Update CHANGELOG.md with `loghub python-lsp/python-lsp-server -m vX.X.X`
5. git add -A && git commit -m "Update Changelog"
6. Update release version in ``_version.py`` (set release version, remove 'dev0')
6. Update release version in `_version.py` (set release version, remove 'dev0')
7. git add -A && git commit -m "Release vX.X.X"
8. python setup.py sdist
9. python setup.py bdist_wheel
10. twine check
11. twine upload
10. twine check dist/*
11. twine upload dist/*
12. git tag -a vX.X.X -m "Release vX.X.X"
13. Update development version in ``_version.py`` (add 'dev0' and increment minor)
13. Update development version in `_version.py` (add 'dev0' and increment minor)
14. git add -A && git commit -m "Back to work"
15. git push upstream master
15. git push upstream develop
16. git push upstream --tags
9 changes: 8 additions & 1 deletion external-deps/python-lsp-server/pylsp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import logging.config
import sys
import time

try:
import ujson as json
Expand All @@ -13,8 +14,10 @@

from .python_lsp import (PythonLSPServer, start_io_lang_server,
start_tcp_lang_server)
from ._version import __version__

LOG_FORMAT = "%(asctime)s UTC - %(levelname)s - %(name)s - %(message)s"
LOG_FORMAT = "%(asctime)s {0} - %(levelname)s - %(name)s - %(message)s".format(
time.localtime().tm_zone)


def add_arguments(parser):
Expand Down Expand Up @@ -55,6 +58,10 @@ def add_arguments(parser):
help="Increase verbosity of log output, overrides log config file"
)

parser.add_argument(
'-V', '--version', action='version', version='%(prog)s v' + __version__
)


def main():
parser = argparse.ArgumentParser()
Expand Down
2 changes: 2 additions & 0 deletions external-deps/python-lsp-server/pylsp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def _merge_dicts_(a, b):
if key in a and key in b:
if isinstance(a[key], dict) and isinstance(b[key], dict):
yield (key, dict(_merge_dicts_(a[key], b[key])))
elif isinstance(a[key], list) and isinstance(b[key], list):
yield (key, list(set(a[key] + b[key])))
elif b[key] is not None:
yield (key, b[key])
else:
Expand Down
2 changes: 1 addition & 1 deletion external-deps/python-lsp-server/pylsp/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"""PyLSP versioning information."""


VERSION_INFO = (1, 1, 0, 'dev0')
VERSION_INFO = (1, 2, 0, 'dev0')
__version__ = '.'.join(map(str, VERSION_INFO))
7 changes: 7 additions & 0 deletions external-deps/python-lsp-server/pylsp/config/flake8_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
('ignore', 'plugins.flake8.ignore', list),
('max-line-length', 'plugins.flake8.maxLineLength', int),
('select', 'plugins.flake8.select', list),
('per-file-ignores', 'plugins.flake8.perFileIgnores', list),
]


Expand All @@ -48,3 +49,9 @@ def project_config(self, document_path):
files = find_parents(self.root_path, document_path, PROJECT_CONFIGS)
config = self.read_config_from_files(files)
return self.parse_config(config, CONFIG_KEY, OPTIONS)

@classmethod
def _parse_list_opt(cls, string):
if string.startswith("\n"):
return [s.strip().rstrip(",") for s in string.split("\n") if s.strip()]
return [s.strip() for s in string.split(",") if s.strip()]
Loading