openlawlibrary / pygls

A pythonic generic language server
https://pygls.readthedocs.io/en/latest/
Apache License 2.0
568 stars 103 forks source link

Generate server methods based on `lsprotocol` type definitions #489

Closed alcarney closed 3 weeks ago

alcarney commented 1 month ago

487 introduced some breaking changes, so this PR is taking the opportunity to make a few more that were going to be part of #418.

Similar to the BaseLanguageClient, this PR updates the code generation script to now also produce a BaseLanguageServer with all the server side methods generated based on the type definitions provided by lsprotocol

Not only does this improve consistency and remove the need for the duplicated methods on the LanguageServerProtocol class (Closes #306), we also get all the server side methods we were missing!

Aside from the obvious naming/argument changes, this also introduces the following changes (which we will need to document in a migration guide)

Finally, the base Server class has been tidied up a little

TODO

Code review checklist (for code reviewer to complete)

Automated linters

You can run the lints that are run on CI locally with:

poetry install --all-extras --with dev
poetry run poe lint
alcarney commented 3 weeks ago

Added an initial draft of the migration guide, there are a few more changes we can make (e.g. removing deprecated methods) so I expect it will take a few more revisions to get right.

So this should be ready for a review now.

That said, the lint job has started failing and I'm not entirely sure why...

Run source $VENV
/home/runner/work/_temp/0f22c65c-8345-4c8d-8709-e3f4d68c7c6b.sh: /home/runner/work/pygls/pygls/.venv/bin/poe: /home/runner/work/pygls/pygls/.venv/bin/python: bad interpreter: No such file or directory
Error: Process completed with exit code 126.
tombh commented 3 weeks ago

I have a PR for the failing CI issue: https://github.com/openlawlibrary/pygls/pull/491

alcarney commented 3 weeks ago

Do the new docs get automatically published on merge to main?

Yes, https://pygls.readthedocs.io/en/latest/ points to main

It might be good to have an update in our main README about how we're looking for beta testers for the breaking changes and a link to the migration docs?

I've added a note to the README, though there are a few more changes we should make before shouting too loudly about it :)