Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Aug 22, 2024
2 parents bf2c3ce + 3215ea6 commit 0512e56
Show file tree
Hide file tree
Showing 60 changed files with 505 additions and 483 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
OS: 'linux'
timeout-minutes: 2
steps:
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: static-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: static-pip-
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# TODO: check with Python 3, but need to fix the
# errors first
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
PYTHON_VERSION: ['3.10', '3.9', '3.8']
timeout-minutes: 10
steps:
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.PYTHON_VERSION }}
architecture: 'x64'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
jobs:
build:
name: Mac Py${{ matrix.PYTHON_VERSION }}
runs-on: macos-latest
runs-on: macos-13
env:
CI: 'true'
OS: 'macos'
Expand All @@ -27,13 +27,13 @@ jobs:
PYTHON_VERSION: ['3.10', '3.9', '3.8']
timeout-minutes: 10
steps:
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.PYTHON_VERSION }}
architecture: 'x64'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
PYTHON_VERSION: ['3.10', '3.9', '3.8']
timeout-minutes: 10
steps:
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: ${{ runner.os }}-${{ matrix.PYTHON_VERSION }}-pip-
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.PYTHON_VERSION }}
architecture: 'x64'
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# History of changes

## Version 1.11.0 (2024/03/29)

### New features

* Remove the `rope_rename` plugin. People that were using it need to install
the `pylsp-rope` third-party plugin instead.
* Add support for Pylint 3.1

### Issues Closed

* [Issue 255](https://github.com/python-lsp/python-lsp-server/issues/255) - Confusion about rename support ([PR 515](https://github.com/python-lsp/python-lsp-server/pull/515) by [@doolio](https://github.com/doolio))

In this release 1 issue was closed.

### Pull Requests Merged

* [PR 543](https://github.com/python-lsp/python-lsp-server/pull/543) - Bump pylint to `>=3.1,<4`, by [@bnavigator](https://github.com/bnavigator)
* [PR 541](https://github.com/python-lsp/python-lsp-server/pull/541) - Add fallback for `ujson` import, by [@Savalek](https://github.com/Savalek)
* [PR 538](https://github.com/python-lsp/python-lsp-server/pull/538) - Remove `.config/flake8` reference in Readme, by [@justin-f-perez](https://github.com/justin-f-perez)
* [PR 536](https://github.com/python-lsp/python-lsp-server/pull/536) - Fix isort plugin name in Readme, by [@Piraty](https://github.com/Piraty)
* [PR 515](https://github.com/python-lsp/python-lsp-server/pull/515) - Remove built-in `rope_rename` plugin, by [@doolio](https://github.com/doolio) ([255](https://github.com/python-lsp/python-lsp-server/issues/255))
* [PR 470](https://github.com/python-lsp/python-lsp-server/pull/470) - Add contributing guide to setup dev environment, by [@staticf0x](https://github.com/staticf0x)

In this release 6 pull requests were closed.

----

## Version 1.10.1 (2024/03/12)

### Issues Closed

* [Issue 529](https://github.com/python-lsp/python-lsp-server/issues/529) - Autoimports: sqlite3.OperationalError: database is locked ([PR 530](https://github.com/python-lsp/python-lsp-server/pull/530) by [@last-partizan](https://github.com/last-partizan))

In this release 1 issue was closed.

### Pull Requests Merged

* [PR 530](https://github.com/python-lsp/python-lsp-server/pull/530) - Fix progress reporting with autoimport plugin, by [@last-partizan](https://github.com/last-partizan) ([529](https://github.com/python-lsp/python-lsp-server/issues/529))
* [PR 528](https://github.com/python-lsp/python-lsp-server/pull/528) - Improve error message about missing `websockets` module, by [@tomplus](https://github.com/tomplus)

In this release 2 pull requests were closed.

----

## Version 1.10.0 (2024/01/21)

### New features
Expand Down
2 changes: 2 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
| `pylsp.plugins.flake8.enabled` | `boolean` | Enable or disable the plugin. | `false` |
| `pylsp.plugins.flake8.exclude` | `array` of `string` items | List of files or directories to exclude. | `[]` |
| `pylsp.plugins.flake8.extendIgnore` | `array` of `string` items | List of errors and warnings to append to ignore list. | `[]` |
| `pylsp.plugins.flake8.extendSelect` | `array` of `string` items | List of errors and warnings to append to select list. | `[]` |
| `pylsp.plugins.flake8.executable` | `string` | Path to the flake8 executable. | `"flake8"` |
| `pylsp.plugins.flake8.filename` | `string` | Only check for filenames matching the patterns in this list. | `null` |
| `pylsp.plugins.flake8.hangClosing` | `boolean` | Hang closing bracket instead of matching indentation of opening bracket's line. | `null` |
Expand All @@ -20,6 +21,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_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
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Setup the environment

1. Clone the repo: `git clone git@github.com:python-lsp/python-lsp-server.git`
2. Create the virtual environment: `python -m venv .venv`
3. Activate: `source .venv/bin/activate`
4. Install an editable installation: `pip install -e .`
- This will ensure you'll see your edits immediately without reinstalling the project
5. Configure your editor to point the pylsp executable to the one in `.venv`

## Trying out if it works

Go to file `pylsp/python_lsp.py`, function `start_io_lang_server`,
and on the first line of the function, add some logging:

```py
log.info("It works!")
```

Save the file, restart the LSP server and you should see the log line:

```
2023-10-12 16:46:38,320 CEST - INFO - pylsp._utils - It works!
```

Now the project is setup in a way you can quickly iterate change you want to add.

# Running tests

1. Install runtime dependencies: `pip install .[all]`
2. Install test dependencies: `pip install .[test]`
3. Run `pytest`: `pytest -v`

## Useful pytest options

- To run a specific test file, use `pytest test/test_utils.py`
- To run a specific test function within a test file,
use `pytest test/test_utils.py::test_debounce`
- To run tests matching a certain expression, use `pytest -k format`
- To increase verbosity of pytest, use `pytest -v` or `pytest -vv`
- To enter a debugger on failed tests, use `pytest --pdb`
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sudo apt-get install python3-pylsp
or Fedora Linux

```
sudo dnf install python-lsp-server
sudo dnf install python3-lsp-server
```

or Arch Linux
Expand All @@ -82,7 +82,7 @@ apk add py3-lsp-server
Installing these plugins will add extra functionality to the language server:

- [pylsp-mypy](https://github.com/Richardk2n/pylsp-mypy): [MyPy](http://mypy-lang.org/) type checking for Python >=3.8.
- [pyls-isort](https://github.com/chantera/python-lsp-isort): code formatting using [isort](https://github.com/PyCQA/isort) (automatic import sorting).
- [python-lsp-isort](https://github.com/chantera/python-lsp-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.
- [pylsp-rope](https://github.com/python-rope/pylsp-rope): Extended refactoring capabilities using [Rope](https://github.com/python-rope/rope).
Expand All @@ -101,7 +101,7 @@ Like all language servers, configuration can be passed from the client that talk
`python-lsp-server` depends on other tools, like flake8 and pycodestyle. These tools can be configured via settings passed from the client (as above), or alternatively from other configuration sources. The following sources are available:

- `pycodestyle`: discovered in `~/.config/pycodestyle`, `setup.cfg`, `tox.ini` and `pycodestyle.cfg`.
- `flake8`: discovered in `~/.config/flake8`, `.flake8`, `setup.cfg` and `tox.ini`
- `flake8`: discovered in `.flake8`, `setup.cfg` and `tox.ini`

The default configuration sources are `pycodestyle` and `pyflakes`. If you would like to use `flake8`, you will need to:

Expand Down
6 changes: 3 additions & 3 deletions pylsp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)


def add_arguments(parser):
def add_arguments(parser) -> None:
parser.description = "Python Language Server"

parser.add_argument(
Expand Down Expand Up @@ -67,7 +67,7 @@ def add_arguments(parser):
)


def main():
def main() -> None:
parser = argparse.ArgumentParser()
add_arguments(parser)
args = parser.parse_args()
Expand All @@ -94,7 +94,7 @@ def _binary_stdio():
return stdin, stdout


def _configure_logger(verbose=0, log_config=None, log_file=None):
def _configure_logger(verbose=0, log_config=None, log_file=None) -> None:
root_logger = logging.root

if log_config:
Expand Down
6 changes: 3 additions & 3 deletions pylsp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def find_parents(root, path, names):
return []

if not os.path.commonprefix((root, path)):
log.warning("Path %s not in %s", path, root)
log.warning("Path %r not in %r", path, root)
return []

# Split the relative by directory, generate all the parent directories, then check each of them.
Expand Down Expand Up @@ -175,8 +175,8 @@ def escape_plain_text(contents: str) -> str:
"""
Format plain text to display nicely in environments which do not respect whitespaces.
"""
contents = contents.replace("\t", "\u00A0" * 4)
contents = contents.replace(" ", "\u00A0" * 2)
contents = contents.replace("\t", "\u00a0" * 4)
contents = contents.replace(" ", "\u00a0" * 2)
return contents


Expand Down
6 changes: 3 additions & 3 deletions pylsp/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _hookexec(


class Config:
def __init__(self, root_uri, init_opts, process_id, capabilities):
def __init__(self, root_uri, init_opts, process_id, capabilities) -> None:
self._root_path = uris.to_fs_path(root_uri)
self._root_uri = root_uri
self._init_opts = init_opts
Expand Down Expand Up @@ -185,14 +185,14 @@ def plugin_settings(self, plugin, document_path=None):
.get(plugin, {})
)

def update(self, settings):
def update(self, settings) -> None:
"""Recursively merge the given settings into the current settings."""
self.settings.cache_clear()
self._settings = settings
log.info("Updated settings to %s", self._settings)
self._update_disabled_plugins()

def _update_disabled_plugins(self):
def _update_disabled_plugins(self) -> None:
# All plugins default to enabled
self._disabled_plugins = [
plugin
Expand Down
1 change: 1 addition & 0 deletions pylsp/config/flake8_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# flake8
("exclude", "plugins.flake8.exclude", list),
("extend-ignore", "plugins.flake8.extendIgnore", list),
("extend-select", "plugins.flake8.extendSelect", list),
("filename", "plugins.flake8.filename", list),
("hang-closing", "plugins.flake8.hangClosing", bool),
("ignore", "plugins.flake8.ignore", list),
Expand Down
15 changes: 14 additions & 1 deletion pylsp/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
},
"description": "List of errors and warnings to append to ignore list."
},
"pylsp.plugins.flake8.extendSelect": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "List of errors and warnings to append to select list."
},
"pylsp.plugins.flake8.executable": {
"type": "string",
"default": "flake8",
Expand Down Expand Up @@ -143,6 +151,11 @@
},
"description": "Define extra paths for jedi.Script."
},
"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`"
},
"pylsp.plugins.jedi.env_vars": {
"type": [
"object",
Expand Down Expand Up @@ -500,4 +513,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."
}
}
}
}
14 changes: 7 additions & 7 deletions pylsp/config/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
class ConfigSource:
"""Base class for implementing a config source."""

def __init__(self, root_path):
def __init__(self, root_path) -> None:
self.root_path = root_path
self.is_windows = sys.platform == "win32"
self.xdg_home = os.environ.get(
"XDG_CONFIG_HOME", os.path.expanduser("~/.config")
)

def user_config(self):
def user_config(self) -> None:
"""Return user-level (i.e. home directory) configuration."""
raise NotImplementedError()

def project_config(self, document_path):
def project_config(self, document_path) -> None:
"""Return project-level (i.e. workspace directory) configuration."""
raise NotImplementedError()

Expand Down Expand Up @@ -53,16 +53,16 @@ def _get_opt(cls, config, key, option, opt_type):
if not config.has_option(key, opt_key):
continue

if opt_type == bool:
if opt_type is bool:
return config.getboolean(key, opt_key)

if opt_type == int:
if opt_type is int:
return config.getint(key, opt_key)

if opt_type == str:
if opt_type is str:
return config.get(key, opt_key)

if opt_type == list:
if opt_type is list:
return cls._parse_list_opt(config.get(key, opt_key))

raise ValueError("Unknown option type: %s" % opt_type)
Expand Down
Loading

0 comments on commit 0512e56

Please sign in to comment.