Giter VIP home page Giter VIP logo

lsprotocol's Introduction

Language Server Protocol types code generator & packages

This repository contains packages and tools to generate code for Language Server Protocol types and classes.

It simplifies the creation of language servers for different programming languages by providing a robust and easy-to-use type generation system.

➡️ For instructions on how to use the code generator, refer to the Usage section.

➡️ For instructions on existing plugins and packages for different languages, refer to the table in the Existing packages/plugins section.

➡️ For instructions on how to create additional plugins to support more languages, refer to the Contributing plugins section.

Code Generator Usage

You will need a Python environment to run the generator. Here are the steps:

  1. Create a Python environment: python -m venv .venv

    Note: Python 3.8 is the minimum supported version

  2. Activate the environment: .venv\Scripts\activate (Windows) or source .venv/bin/activate (Linux/macOS)
  3. Install this repo's tool: python -m pip install git+https://github.com/microsoft/lsprotocol.git
  4. Run your plugin. You can use the command line or Nox to run the generator.

Command line

Clone this repository and run generator as a Python module.

For example: python -m generator --plugin dotnet --output-dir ./code

>python -m generator --help
usage: __main__.py [-h] [--model [MODEL [MODEL ...]]] --plugin PLUGIN
                   [--output-dir OUTPUT_DIR]

Generate types from LSP JSON model.

optional arguments:
  -h, --help            show this help message and exit
  --model [MODEL [MODEL ...]], -m [MODEL [MODEL ...]]
                        Path to a model JSON file. By default uses packaged
                        model file.
  --plugin PLUGIN, -p PLUGIN
                        Name of a builtin plugin module. By default uses all
                        plugins.
  --output-dir OUTPUT_DIR, -o OUTPUT_DIR
                        Path to a directory where the generated content is

Using Nox

This project uses Nox as a task runner to run the code generator. You can install Nox and run a build_lsp session to generate code from the spec available in this repo.

> python -m pip install nox
> nox --session build_lsp

You can also use Nox to format code, run tests and run various tasks. Run nox --list to see all available tasks.

Contributing plugins

Adding a new plugin

Follow these steps to generate boilerplate code for a new plugin:

  1. Create a virtual environment for Python using Python >= 3.8 and activate that environment.
    1. If you are using the Python extension for VS Code, you can just run the Python: Create Environment command from the Command Palette. Be sure to select all the requirements.txt files in the repo. This command will install all packages needed and select the newly created environment for you.
  2. Ensure nox is installed.
    1. Run nox --list in the terminal. If Nox is installed, you should see a list of all available sessions. Otherwise, run python -m pip install nox in the activated environment you created above.
  3. Run nox --session create_plugin and follow the prompts to create a new plugin.

Example:

> nox --session create_plugin
nox > Running session create_plugin
nox > Creating virtual environment (virtualenv) using python.exe in .nox\create_plugin
Enter the name of the plugin: java
nox > Created plugin java.
nox > Session create_plugin was successful.

Existing packages/plugins

Below is the list of plugins already created using this package, with their respective package links.

Language Plugin Module Package Status Documentation
Python generator.plugins.python PyPI Active Python package README
Rust generator.plugins.rust Crates Active Rust package README
Dotnet generator.plugins.dotnet Under development

lsprotocol's People

Contributors

0xjonas avatar alcarney avatar anthonykim1 avatar dependabot[bot] avatar dimbleby avatar jhossbach avatar karthiknadig avatar lramos15 avatar luabud avatar microsoft-github-operations[bot] avatar microsoftopensource avatar muffinmad avatar r3m0t avatar rzhao271 avatar timheuer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsprotocol's Issues

Generate Rust types from the official specification

Introduction

It would be awesome if this project also supported generating Rust types from the official spec as well.

This ticket was created in response to a brief discussion with @brettcannon over at ebkalderon/tower-lsp#361 (comment) and is intended track future developments. Happy to get some productive dialog going! 😄

Background

Considering that installing and running a Python package as a prerequisite from a cargo build would be pretty messy, I would assume this effort would likely entail the creation of a pure Rust equivalent that can consume the same spec. Consider the following setup:

  • An lsprotocol-codegen crate would process the spec and generate a Rust file containing type and optionally trait definitions.
    • Provided as a library intended to be used from a Cargo build.rs script.
    • Essentially amounts to a simple generate() function that takes an input spec and some configuration switches.
    • Generates an lsprotocol.rs file in $OUT_DIR that can be included in a Rust project with:
      include!(concat!(env!("OUT_DIR"), "/lsprotocol.rs"));
    • Could also ship with a src/bin.rs that wraps this library and provides a CLI interface, should others prefer to use that.
    • See other popular build helper crates for an example of this interface, e.g. prost-build (Protobuf), tonic-build (gRPC), and dbus-codegen (dbus) for prior art.
    • Consider using schemafy for processing the JSON Schema (draft 4) file in this repo.
  • An lsprotocol crate would export native Rust types to the user.
    • Main crate that most downstream users would consume.
    • These types would be generated in advance by lsprotocol-codegen and vendored directly into the repository.
    • Updated periodically on an as-needed basis (perhaps automatically using a GitHub CI job) and then published to Crates.io.
    • Generated types would implement most common std traits (Clone, Debug, Default, Eq, PartialEq, etc).
    • Generated types would implement serde::Serialize and serde::Deserialize for easy (de)serialization to and from JSON using serde_json.
    • See the community de-facto standard Rust crate lsp-types for prior art.
      • Something with an API that looks very similar to this would be amazing! Dumb structs with all pub fields, enums used to represent multiple states, and everything implements Serialize and Deserialize.
      • The included Notification and Request traits are very handy for generic code. Would love to have that here too.
      • Not sure if the helper macros are essential to replicate. I rarely use them, personally, but some may find them nice.
      • Please note that the structs, enums, traits, and documentation in this particular crate are all updated by hand, at present. As such, a source of auto-generated Rust types would be wonderful to have (less manual labor for maintainers while delivering quicker updates to downstream users).

Ideally, the above Rust crates would share the same spec file as the Python project so the codegen for both could be tested for correctness in CI.

Open Questions

One notable open question is how we should best handle "proposed" features. It would be nice if downstream users of lsprotocol could opt into certain not-quite-standardized features in advance, provided they explicitly agree to the API instability when switching this on. The de-facto community standard crate lsp-types does precisely this (as does my own downstream LSP library for Rust tower-lsp) using an off-by-default proposed = [] Cargo feature which, if enabled at compile-time, would activate these types in the public API.

If we choose to offer the same thing here, it would be fairly trivial on the surface: the lsprotocol crate would expose Rust types for the entire superset of the LSP specification, marking certain types #[cfg(feature = "proposed")] and offering users an off-by-default proposed = [] feature they can choose to enable if they wish. This would fall in line with other popular LSP crates used in the community today.

However, what remains to be seen is how fancy we'd like to be with lsprotocol-codegen. Consider the following questions:

  1. Does the current spec file used in this repo include proposed features at all? Is this something the equivalent Python lsprotocol package supports today? Is this something we even want to support?
  2. If we do want to support proposed protocol features in this crate, how should lsprotocol-codegen implement said support?
    • Presumably, lsprotocol-codegen would output a single lsprotocol.rs file containing all types with some marked #[cfg(feature = "proposed")], ready to be vendored into this repo as lsprotocol/src/lib.rs and published directly to Crates.io as the lsprotocol crate.
    • Should we add a config switch to lsprotocol_codegen::generate() and the CLI interface (if we choose to provide one) for the user to change the "proposed" feature name string in the output #[cfg]s to something else?
    • Should we support a config switch for not including types for proposed features in the lsprotocol.rs output entirely?
    • I don't think either of the above two bullets are at all necessary for an MVP, but may be nice to have down the road.

Another open question is regarding specification version support in general. Do we support the latest version of the LSP spec only? Or do we want to be able to perform codegen for all available versions of the spec? I presume the former, but I think it's good to get solid confirmation on this.

Versioning

Crates published to Crates.io are expected to adhere to semantic versioning as strictly as possible. This is quite significant for us because adding new pub fields to an existing struct or new variants to an existing enum is considered a breaking API change, unless those types are explicitly marked #[non_exhaustive] (reference), at which point users are forced to include a _ => fallthrough case or wildcard .. when matching on or destructuring those types.

We should not annotate every single type in the generated code with #[non_exhaustive], of course, since this would severely hamper the crate's usability. Downstream code would not be able to directly construct instances of any of the generated structs, even with ..Default::default() syntax, even though all fields are pub (see bug report rust-lang/rust#70564). We should carefully consider whether or not to mark certain types #[non_exhaustive] and when it would be most applicable to do so.

Thankfully, serde seems to support serializing from and deserializing to #[non_exhaustive] types out of the box, so this should not be a factor in us deciding when or not to apply this attribute in the lsprotocol-codegen output.

Unable to structure `NotebookDocumentSyncOptions`

>>> options = {'notebookSelector': [{'cells': [{'language': 'python'}]}]}

>>> converter.structure(options, NotebookDocumentSyncOptions)
  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 309, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "<cattrs generated structure lsprotocol.types.NotebookDocumentSyncOptions>", line 15, in structure_NotebookDocumentSyncOptions
  | cattrs.errors.ClassValidationError: While structuring NotebookDocumentSyncOptions (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.NotebookDocumentSyncOptions>", line 5, in structure_NotebookDocumentSyncOptions
    |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 495, in _structure_list
    |     handler = self._structure_func.dispatch(elem_type)
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/dispatch.py", line 49, in _dispatch
    |     return self._function_dispatch.dispatch(cl)
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/dispatch.py", line 131, in dispatch
    |     return handler(typ)
    |            ^^^^^^^^^^^^
    |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 390, in _gen_attrs_union_structure
    |     dis_fn = self._get_dis_func(cl)
    |              ^^^^^^^^^^^^^^^^^^^^^^
    |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 677, in _get_dis_func
    |     return create_uniq_field_dis_func(*union_types)
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/disambiguators.py", line 39, in create_uniq_field_dis_func
    |     raise ValueError(m)
    | ValueError: <class 'lsprotocol.types.NotebookDocumentSyncOptionsNotebookSelectorType1'> has no usable unique attributes.
    | Structuring class NotebookDocumentSyncOptions @ attribute notebook_selector
    +------------------------------------
>>> 

This isn't the usual "missing structure hook" error - so not sure if I am missing something? 🤔

Although, that said this InitializeResult instance is enough to get VSCode to switch on the notebook document sync messages

{
    "capabilities": {
        "textDocumentSync": {
            "openClose": true,
            "change": 2,
            "willSave": false,
            "willSaveWaitUntil": false,
            "save": false
        },
        "notebookDocumentSync": {
            "notebookSelector": [
                {
                    "cells": [
                        {
                            "language": "python"
                        }
                    ]
                }
            ]
        },
        "executeCommandProvider": {
            "commands": []
        },
        "inlayHintProvider": {
            "resolveProvider": true
        },
        "workspace": {
            "workspaceFolders": {
                "supported": true,
                "changeNotifications": true
            },
            "fileOperations": {}
        }
    },
    "serverInfo": {
        "name": "inlay-hint-server",
        "version": "v0.1"
    }
}

Address issues reported by `mypy --strict`

(.venv) C:\GIT\LSP\lsprotocol>mypy --strict lsprotocol
lsprotocol\validators.py:13: error: Missing type parameters for generic type "Attribute"
lsprotocol\validators.py:28: error: Missing type parameters for generic type "Attribute"
lsprotocol\types.py:660: error: Cannot resolve name "LSPArray" (possible cyclic definition)
lsprotocol\types.py:660: error: Cannot resolve name "LSPAny" (possible cyclic definition)
lsprotocol\types.py:664: error: Cannot resolve name "LSPAny" (possible cyclic definition)
lsprotocol\types.py:1000: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
lsprotocol\types.py:1000: note: This violates the Liskov substitution principle
lsprotocol\types.py:1000: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
lsprotocol\types.py:1000: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
lsprotocol\types.py:1000: note:     def __eq__(self, other: object) -> bool:
lsprotocol\types.py:1000: note:         if not isinstance(other, Location):
lsprotocol\types.py:1000: note:             return NotImplemented
lsprotocol\types.py:1000: note:         return <logic to compare two Location instances>
lsprotocol\types.py:1000: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:1000: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:4932: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
lsprotocol\types.py:4932: note: This violates the Liskov substitution principle
lsprotocol\types.py:4932: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
lsprotocol\types.py:4932: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
lsprotocol\types.py:4932: note:     def __eq__(self, other: object) -> bool:
lsprotocol\types.py:4932: note:         if not isinstance(other, Range):
lsprotocol\types.py:4932: note:             return NotImplemented
lsprotocol\types.py:4932: note:         return <logic to compare two Range instances>
lsprotocol\types.py:4932: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:4932: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:5045: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
lsprotocol\types.py:5045: note: This violates the Liskov substitution principle
lsprotocol\types.py:5045: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
lsprotocol\types.py:5045: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
lsprotocol\types.py:5045: note:     def __eq__(self, other: object) -> bool:
lsprotocol\types.py:5045: note:         if not isinstance(other, Position):
lsprotocol\types.py:5045: note:             return NotImplemented
lsprotocol\types.py:5045: note:         return <logic to compare two Position instances>
lsprotocol\types.py:5045: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:5045: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:5050: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:5050: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:5134: error: Name "kind" already defined on line 5128
lsprotocol\types.py:5160: error: Name "kind" already defined on line 5151
lsprotocol\types.py:5183: error: Name "kind" already defined on line 5177
lsprotocol\types.py:8785: error: Variable "lsprotocol.types.DefinitionLink" is not valid as a type
lsprotocol\types.py:8785: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:8811: error: Variable "lsprotocol.types.DefinitionLink" is not valid as a type
lsprotocol\types.py:8811: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:8961: error: Variable "lsprotocol.types.DeclarationLink" is not valid as a type
lsprotocol\types.py:8961: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:9829: error: Variable "lsprotocol.types.DefinitionLink" is not valid as a type
lsprotocol\types.py:9829: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:11405: error: Function is missing a type annotation for one or more arguments
lsprotocol\types.py:11607: error: Function is missing a type annotation for one or more arguments
lsprotocol\types.py:11969: error: Function is missing a type annotation for one or more arguments
lsprotocol\_hooks.py:18: error: Function is missing a return type annotation
lsprotocol\_hooks.py:25: error: Function is missing a return type annotation
lsprotocol\_hooks.py:35: error: Function is missing a return type annotation
lsprotocol\_hooks.py:42: error: Function is missing a return type annotation
lsprotocol\_hooks.py:54: error: Function is missing a return type annotation
lsprotocol\_hooks.py:61: error: Function is missing a return type annotation
lsprotocol\_hooks.py:73: error: Function is missing a return type annotation
lsprotocol\_hooks.py:85: error: Function is missing a return type annotation
lsprotocol\_hooks.py:92: error: Function is missing a return type annotation
lsprotocol\_hooks.py:99: error: Function is missing a return type annotation
lsprotocol\_hooks.py:106: error: Function is missing a return type annotation
lsprotocol\_hooks.py:113: error: Function is missing a return type annotation
lsprotocol\_hooks.py:125: error: Function is missing a return type annotation
lsprotocol\_hooks.py:132: error: Function is missing a return type annotation
lsprotocol\_hooks.py:139: error: Function is missing a return type annotation
lsprotocol\_hooks.py:146: error: Function is missing a return type annotation
lsprotocol\_hooks.py:153: error: Function is missing a return type annotation
lsprotocol\_hooks.py:165: error: Function is missing a return type annotation
lsprotocol\_hooks.py:177: error: Function is missing a return type annotation
lsprotocol\_hooks.py:189: error: Function is missing a return type annotation
lsprotocol\_hooks.py:201: error: Function is missing a return type annotation
lsprotocol\_hooks.py:211: error: Function is missing a return type annotation
lsprotocol\_hooks.py:221: error: Function is missing a return type annotation
lsprotocol\_hooks.py:233: error: Function is missing a return type annotation
lsprotocol\_hooks.py:245: error: Function is missing a return type annotation
lsprotocol\_hooks.py:255: error: Function is missing a return type annotation
lsprotocol\_hooks.py:263: error: Function is missing a return type annotation
lsprotocol\_hooks.py:270: error: Function is missing a return type annotation
lsprotocol\_hooks.py:276: error: Function is missing a return type annotation
lsprotocol\_hooks.py:286: error: Function is missing a return type annotation
lsprotocol\_hooks.py:304: error: Function is missing a return type annotation
lsprotocol\_hooks.py:320: error: Function is missing a return type annotation
lsprotocol\_hooks.py:339: error: Function is missing a return type annotation
lsprotocol\_hooks.py:354: error: Function is missing a return type annotation
lsprotocol\converters.py:23: error: Argument 1 to "filter" has incompatible type "Callable[[Any], bool]"; expected "Callable[[Tuple[str, object]], TypeGuard[bool]]"
lsprotocol\converters.py:23: error: Argument 1 to "has" has incompatible type "object"; expected "type"
lsprotocol\converters.py:23: error: Value of type "bool" is not indexable
lsprotocol\converters.py:24: error: "bool" object is not iterable
lsprotocol\converters.py:25: error: Cannot determine type of "value"
lsprotocol\converters.py:34: error: Argument 1 to "_register_generated_hooks" has incompatible type "Optional[Converter]"; expected 
"Converter"
lsprotocol\converters.py:46: error: Returning Any from function declared to return "Union[LSPObject, List[Any], str, int, float, bool, None]"
lsprotocol\converters.py:50: error: Returning Any from function declared to return "Union[LSPObject, List[Any], str, int, float, bool, None]"
lsprotocol\converters.py:52: error: Returning Any from function declared to return "Union[LSPObject, List[Any], str, int, float, bool, None]"
lsprotocol\converters.py:124: error: Name "LSPAny" is not defined
lsprotocol\converters.py:168: error: Function is missing a return type annotation
Found 67 errors in 4 files (checked 5 source files)

(.venv) C:\GIT\LSP\lsprotocol>mypy lsprotocol          
lsprotocol\types.py:660: error: Cannot resolve name "LSPArray" (possible cyclic definition)
lsprotocol\types.py:660: error: Cannot resolve name "LSPAny" (possible cyclic definition)
lsprotocol\types.py:664: error: Cannot resolve name "LSPAny" (possible cyclic definition)
lsprotocol\types.py:1000: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
lsprotocol\types.py:1000: note: This violates the Liskov substitution principle
lsprotocol\types.py:1000: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
lsprotocol\types.py:1000: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
lsprotocol\types.py:1000: note:     def __eq__(self, other: object) -> bool:
lsprotocol\types.py:1000: note:         if not isinstance(other, Location):
lsprotocol\types.py:1000: note:             return NotImplemented
lsprotocol\types.py:1000: note:         return <logic to compare two Location instances>
lsprotocol\types.py:1000: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:1000: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:4932: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
lsprotocol\types.py:4932: note: This violates the Liskov substitution principle
lsprotocol\types.py:4932: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
lsprotocol\types.py:4932: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
lsprotocol\types.py:4932: note:     def __eq__(self, other: object) -> bool:
lsprotocol\types.py:4932: note:         if not isinstance(other, Range):
lsprotocol\types.py:4932: note:             return NotImplemented
lsprotocol\types.py:4932: note:         return <logic to compare two Range instances>
lsprotocol\types.py:4932: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:4932: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:5045: error: Argument 1 of "__eq__" is incompatible with supertype "object"; supertype defines the argument type as "object"
lsprotocol\types.py:5045: note: This violates the Liskov substitution principle
lsprotocol\types.py:5045: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
lsprotocol\types.py:5045: note: It is recommended for "__eq__" to work with arbitrary objects, for example:
lsprotocol\types.py:5045: note:     def __eq__(self, other: object) -> bool:
lsprotocol\types.py:5045: note:         if not isinstance(other, Position):
lsprotocol\types.py:5045: note:             return NotImplemented
lsprotocol\types.py:5045: note:         return <logic to compare two Position instances>
lsprotocol\types.py:5045: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:5045: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:5050: error: Variable "builtins.NotImplemented" is not valid as a type
lsprotocol\types.py:5050: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:5134: error: Name "kind" already defined on line 5128
lsprotocol\types.py:5160: error: Name "kind" already defined on line 5151
lsprotocol\types.py:5183: error: Name "kind" already defined on line 5177
lsprotocol\types.py:8785: error: Variable "lsprotocol.types.DefinitionLink" is not valid as a type
lsprotocol\types.py:8785: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:8811: error: Variable "lsprotocol.types.DefinitionLink" is not valid as a type
lsprotocol\types.py:8811: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:8961: error: Variable "lsprotocol.types.DeclarationLink" is not valid as a type
lsprotocol\types.py:8961: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\types.py:9829: error: Variable "lsprotocol.types.DefinitionLink" is not valid as a type
lsprotocol\types.py:9829: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
lsprotocol\converters.py:23: error: Argument 1 to "filter" has incompatible type "Callable[[Any], bool]"; expected "Callable[[Tuple[str, object]], TypeGuard[bool]]"
lsprotocol\converters.py:23: error: Argument 1 to "has" has incompatible type "object"; expected "type"
lsprotocol\converters.py:23: error: Value of type "bool" is not indexable
lsprotocol\converters.py:24: error: "bool" object is not iterable
lsprotocol\converters.py:25: error: Cannot determine type of "value"
lsprotocol\converters.py:34: error: Argument 1 to "_register_generated_hooks" has incompatible type "Optional[Converter]"; expected 
"Converter"
lsprotocol\converters.py:124: error: Name "LSPAny" is not defined
Found 24 errors in 2 files (checked 5 source files)

Update LSP schema and model

LSP Schema has changed. Please update the generator.
Schema: source
Model: source

Instructions:

  1. Setup a virtual environment and install nox.
  2. Install all requirements for generator.
  3. Run nox --session update_lsp.

Hashes:

  • schema: 6a3119d483b7dcfe2e6d42dd2af945de1b7871c7238d846a97f6566d9811ae9c
  • model: 89fc1a2dd8552b340dc0511c76b3e3207d5399b27064f78186d83d16dbb12a2d

Reading full context

Hi, I wanted to ask how to read the full context (like the actual line of code or the lines of code previous to the current buffer) from CompletionParams.

Thanks.

Missing structure hook for `InlayHint`

Unable to deserialize message
  + Exception Group Traceback (most recent call last):
  |   File "/var/home/alex/Projects/pygls/pygls/protocol.py", line 405, in _deserialize_message
  |     return self._converter.structure(data, request_type)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 309, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "<cattrs generated structure lsprotocol.types.InlayHintResolveRequest>", line 26, in structure_InlayHintResolveRequest
  |     if errors: raise __c_cve('While structuring ' + 'InlayHintResolveRequest', errors, __cl)
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | cattrs.errors.ClassValidationError: While structuring InlayHintResolveRequest (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.InlayHintResolveRequest>", line 10, in structure_InlayHintResolveRequest
    |     res['params'] = __c_structure_params(o['params'], __c_type_params)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "<cattrs generated structure lsprotocol.types.InlayHint>", line 50, in structure_InlayHint
    |     if errors: raise __c_cve('While structuring ' + 'InlayHint', errors, __cl)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | cattrs.errors.ClassValidationError: While structuring InlayHint (1 sub-exception)
    | Structuring class InlayHintResolveRequest @ attribute params
    +-+---------------- 1 ----------------
      | Traceback (most recent call last):
      |   File "<cattrs generated structure lsprotocol.types.InlayHint>", line 10, in structure_InlayHint
      |     res['label'] = __c_structure_label(o['label'], __c_type_label)
      |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 377, in _structure_error
      |     raise StructureHandlerNotFoundError(msg, type_=cl)
      | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.List[lsprotocol.types.InlayHintLabelPart]]. Register a structure hook for it.
      | Structuring class InlayHint @ attribute label
      +------------------------------------

signature helper does not work for variadic functions

Apologies for not having a minimal reproduction or logs, but your issue tracker offers no explanation of steps and what data you need to fix the problem. Issue also explained in pappasam/jedi-language-server#271, where @dimbleby told me to open up an issue here.

I dont mind having no hints, but errors are very unpleasant:
grafik
Logs and instructions are also here hrsh7th/cmp-nvim-lsp-signature-help#36.

# minimal.py, jedi-language-server version: 0.40.0
print("test"
#                     ^ cursor position
# adding , and subsequent space leads to below error:
# 1. 
# print("test",
# 2.
# print("test", 

Log

[START][2023-06-06 19:02:03] LSP logging initiated
[ERROR][2023-06-06 19:02:03] .../vim/lsp/rpc.lua:734	"rpc"	"/home/user/.local/share/nvim/mason/bin/jedi-language-server"	"stderr"	"ERROR:pygls.protocol:Unable to deserialize message\n  + Exception Group Traceback (most recent call last):\n  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/pygls/protocol.py\", line 401, in _deserialize_message\n  |     return self._converter.structure(data, request_type)\n  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 309, in structure\n  |     return self._structure_func.dispatch(cl)(obj, cl)\n  |   File \"<cattrs generated structure lsprotocol.types.TextDocumentSignatureHelpRequest>\", line 26, in structure_TextDocumentSignatureHelpRequest\n  |     if errors: raise __c_cve('While structuring ' + 'TextDocumentSignatureHelpRequest', errors, __cl)\n  | cattrs.errors.ClassValidationError: While structuring TextDocumentSignatureHelpRequest (1 sub-exception)\n  +-+---------------- 1 ----------------\n    | Exception Group Traceback (most recent call last):\n    |   File \"<cattrs generated structure lsprotocol.types.TextDocumentSignatureHelpRequest>\", line 10, in structure_TextDocumentSignatureHelpRequest\n    |     res['params'] = __c_structure_params(o['params'], __c_type_params)\n    |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpParams>\", line 26, in structure_SignatureHelpParams\n    |     if errors: raise __c_cve('While structuring ' + 'SignatureHelpParams', errors, __cl)\n    | cattrs.errors.ClassValidationError: While structuring SignatureHelpParams (1 sub-exception)\n    | Structuring class TextDocumentSignatureHelpRequest @ attribute params\n    +-+---------------- 1 ----------------\n      | Exception Group Traceback (most recent call last):\n      |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpParams>\", line 16, in structure_SignatureHelpParams\n      |     res['context'] = __c_structure_context(o['context'], __c_type_context)\n      |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 574, in _structure_optional\n      |     return self._structure_func.dispatch(other)(obj, other)\n      |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpContext>\", line 26, in structure_SignatureHelpContext\n      |     if errors: raise __c_cve('While structuring ' + 'SignatureHelpContext', errors, __cl)\n      | cattrs.errors.ClassValidationError: While structuring SignatureHelpContext (1 sub-exception)\n      | Structuring class SignatureHelpParams @ attribute context\n      +-+---------------- 1 ----------------\n        | Exception Group Traceback (most recent call last):\n        |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpContext>\", line 22, in structure_SignatureHelpContext\n        |     res['active_signature_help'] = __c_structure_active_signature_help(o['activeSignatureHelp'], __c_type_active_signature_help)\n        |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 574, in _structure_optional\n        |     return self._structure_func.dispatch(other)(obj, other)\n        |   File \"<cattrs generated structure lsprotocol.types.SignatureHelp>\", line 21, in structure_SignatureHelp\n        |     if errors: raise __c_cve('While structuring ' + 'SignatureHelp', errors, __cl)\n        | cattrs.errors.ClassValidationError: While structuring SignatureHelp (1 sub-exception)\n        | Structuring class SignatureHelpContext @ attribute active_signature_help\n        +-+---------------- 1 ----------------\n          | Exception Group Traceback (most recent call last):\n          |   File \"<cattrs generated structure lsprotocol.types.SignatureHelp>\", line 5, in structure_SignatureHelp\n          |     res['signatures'] = __c_structure_signatures(o['signatures'], __c_type_signatures)\n          |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 510, in _structure_list\n          |     raise IterableValidationError(\n          | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.SignatureInformation] (1 sub-exception)\n          | Structuring class SignatureHelp @ attribute signatures\n          +-+---------------- 1 ----------------\n            | Exception Group Traceback (most recent call last):\n            |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n            |     res.append(handler(e, elem_type))\n            |   File \"<cattrs generated structure lsprotocol.types.SignatureInformation>\", line 27, in structure_SignatureInformation\n            |     if errors: raise __c_cve('While structuring ' + 'SignatureInformation', errors, __cl)\n            | cattrs.errors.ClassValidationError: While structuring SignatureInformation (1 sub-exception)\n            | Structuring typing.List[lsprotocol.types.SignatureInformation] @ index 0\n            +-+---------------- 1 ----------------\n              | Exception Group Traceback (most recent call last):\n              |   File \"<cattrs generated structure lsprotocol.types.SignatureInformation>\", line 17, in structure_SignatureInformation\n              |     res['parameters'] = __c_structure_parameters(o['parameters'], __c_type_parameters)\n              |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 574, in _structure_optional\n              |     return self._structure_func.dispatch(other)(obj, other)\n              |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 510, in _structure_list\n              |     raise IterableValidationError(\n              | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.ParameterInformation] (5 sub-exceptions)\n              | Structuring class SignatureInformation @ attribute parameters\n              +-+---------------- 1 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 0\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 2 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 1\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 3 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 2\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 4 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 3\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 5 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 4\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n\n"
[ERROR][2023-06-06 19:02:03] .../vim/lsp/rpc.lua:734	"rpc"	"/home/user/.local/share/nvim/mason/bin/jedi-language-server"	"stderr"	"ERROR:pygls.protocol:Error receiving data\n  + Exception Group Traceback (most recent call last):\n  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/pygls/protocol.py\", line 401, in _deserialize_message\n  |     return self._converter.structure(data, request_type)\n  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 309, in structure\n  |     return self._structure_func.dispatch(cl)(obj, cl)\n  |   File \"<cattrs generated structure lsprotocol.types.TextDocumentSignatureHelpRequest>\", line 26, in structure_TextDocumentSignatureHelpRequest\n  |     if errors: raise __c_cve('While structuring ' + 'TextDocumentSignatureHelpRequest', errors, __cl)\n  | cattrs.errors.ClassValidationError: While structuring TextDocumentSignatureHelpRequest (1 sub-exception)\n  +-+---------------- 1 ----------------\n    | Exception Group Traceback (most recent call last):\n    |   File \"<cattrs generated structure lsprotocol.types.TextDocumentSignatureHelpRequest>\", line 10, in structure_TextDocumentSignatureHelpRequest\n    |     res['params'] = __c_structure_params(o['params'], __c_type_params)\n    |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpParams>\", line 26, in structure_SignatureHelpParams\n    |     if errors: raise __c_cve('While structuring ' + 'SignatureHelpParams', errors, __cl)\n    | cattrs.errors.ClassValidationError: While structuring SignatureHelpParams (1 sub-exception)\n    | Structuring class TextDocumentSignatureHelpRequest @ attribute params\n    +-+---------------- 1 ----------------\n      | Exception Group Traceback (most recent call last):\n      |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpParams>\", line 16, in structure_SignatureHelpParams\n      |     res['context'] = __c_structure_context(o['context'], __c_type_context)\n      |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 574, in _structure_optional\n      |     return self._structure_func.dispatch(other)(obj, other)\n      |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpContext>\", line 26, in structure_SignatureHelpContext\n      |     if errors: raise __c_cve('While structuring ' + 'SignatureHelpContext', errors, __cl)\n      | cattrs.errors.ClassValidationError: While structuring SignatureHelpContext (1 sub-exception)\n      | Structuring class SignatureHelpParams @ attribute context\n      +-+---------------- 1 ----------------\n        | Exception Group Traceback (most recent call last):\n        |   File \"<cattrs generated structure lsprotocol.types.SignatureHelpContext>\", line 22, in structure_SignatureHelpContext\n        |     res['active_signature_help'] = __c_structure_active_signature_help(o['activeSignatureHelp'], __c_type_active_signature_help)\n        |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 574, in _structure_optional\n        |     return self._structure_func.dispatch(other)(obj, other)\n        |   File \"<cattrs generated structure lsprotocol.types.SignatureHelp>\", line 21, in structure_SignatureHelp\n        |     if errors: raise __c_cve('While structuring ' + 'SignatureHelp', errors, __cl)\n        | cattrs.errors.ClassValidationError: While structuring SignatureHelp (1 sub-exception)\n        | Structuring class SignatureHelpContext @ attribute active_signature_help\n        +-+---------------- 1 ----------------\n          | Exception Group Traceback (most recent call last):\n          |   File \"<cattrs generated structure lsprotocol.types.SignatureHelp>\", line 5, in structure_SignatureHelp\n          |     res['signatures'] = __c_structure_signatures(o['signatures'], __c_type_signatures)\n          |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 510, in _structure_list\n          |     raise IterableValidationError(\n          | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.SignatureInformation] (1 sub-exception)\n          | Structuring class SignatureHelp @ attribute signatures\n          +-+---------------- 1 ----------------\n            | Exception Group Traceback (most recent call last):\n            |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n            |     res.append(handler(e, elem_type))\n            |   File \"<cattrs generated structure lsprotocol.types.SignatureInformation>\", line 27, in structure_SignatureInformation\n            |     if errors: raise __c_cve('While structuring ' + 'SignatureInformation', errors, __cl)\n            | cattrs.errors.ClassValidationError: While structuring SignatureInformation (1 sub-exception)\n            | Structuring typing.List[lsprotocol.types.SignatureInformation] @ index 0\n            +-+---------------- 1 ----------------\n              | Exception Group Traceback (most recent call last):\n              |   File \"<cattrs generated structure lsprotocol.types.SignatureInformation>\", line 17, in structure_SignatureInformation\n              |     res['parameters'] = __c_structure_parameters(o['parameters'], __c_type_parameters)\n              |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 574, in _structure_optional\n              |     return self._structure_func.dispatch(other)(obj, other)\n              |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 510, in _structure_list\n              |     raise IterableValidationError(\n              | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.ParameterInformation] (5 sub-exceptions)\n              | Structuring class SignatureInformation @ attribute parameters\n              +-+---------------- 1 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 0\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 2 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 1\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 3 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 2\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 4 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 3\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n                +---------------- 5 ----------------\n                | Exception Group Traceback (most recent call last):\n                |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 502, in _structure_list\n                |     res.append(handler(e, elem_type))\n                |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 15, in structure_ParameterInformation\n                |     if errors: raise __c_cve('While structuring ' + 'ParameterInformation', errors, __cl)\n                | cattrs.errors.ClassValidationError: While structuring ParameterInformation (1 sub-exception)\n                | Structuring typing.List[lsprotocol.types.ParameterInformation] @ index 4\n                +-+---------------- 1 ----------------\n                  | Traceback (most recent call last):\n                  |   File \"<cattrs generated structure lsprotocol.types.ParameterInformation>\", line 5, in structure_ParameterInformation\n                  |     res['label'] = __c_structure_label(o['label'], __c_type_label)\n                  |   File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/cattrs/converters.py\", line 377, in _structure_error\n                  |     raise StructureHandlerNotFoundError(msg, type_=cl)\n                  | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, typing.Tuple[int, int]]. Register a structure hook for it.\n                  | Structuring class ParameterInformation @ attribute label\n                  +------------------------------------\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/pygls/protocol.py\", line 507, in data_received\n    self._data_received(data)\n  File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/pygls/protocol.py\", line 539, in _data_received\n    json.loads(body.decode(self.CHARSET),\n  File \"/usr/lib/python3.8/json/__init__.py\", line 370, in loads\n    return cls(**kw).decode(s)\n  File \"/usr/lib/python3.8/json/decoder.py\", line 337, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n  File \"/usr/lib/python3.8/json/decoder.py\", line 353, in raw_decode\n    obj, end = self.scan_once(s, idx)\n  File \"/home/user/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.8/site-packages/pygls/protocol.py\", line 415, in _deserialize_message\n    raise JsonRpcInvalidParams() from exc\npygls.exceptions.JsonRpcInvalidParams: Invalid Params\n"

Let me know, what further logs or instructions you need to reproduce the problem.

Missing structure hook(s?) for notebook types

For example DidOpenNotebookDocumentParams

{
    "notebookDocument": {
        "uri": "untitled:Untitled-1.ipynb?jupyter-notebook",
        "notebookType": "jupyter-notebook",
        "version": 0,
        "cells": [
            {
                "kind": 2,
                "document": "vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D",
                "metadata": {
                    "custom": {
                        "metadata": {}
                    }
                }
            }
        ],
        "metadata": {
            "custom": {
                "cells": [],
                "metadata": {
                    "orig_nbformat": 4,
                    "language_info": {
                        "name": "python"
                    }
                }
            },
            "indentAmount": " "
        }
    },
    "cellTextDocuments": [
        {
            "uri": "vscode-notebook-cell:Untitled-1.ipynb?jupyter-notebook#W0sdW50aXRsZWQ%3D",
            "languageId": "python",
            "version": 1,
            "text": ""
        }
    ]
}

Error message

Unable to deserialize message
  + Exception Group Traceback (most recent call last):
  |   File "/var/home/alex/Projects/pygls/pygls/protocol.py", line 415, in _deserialize_message
  |     return self._converter.structure(data, notification_type)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 309, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "<cattrs generated structure lsprotocol.types.NotebookDocumentDidOpenNotification>", line 21, in structure_NotebookDocumentDidOpenNotification
  |     if errors: raise __c_cve('While structuring ' + 'NotebookDocumentDidOpenNotification', errors, __cl)
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | cattrs.errors.ClassValidationError: While structuring NotebookDocumentDidOpenNotification (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.NotebookDocumentDidOpenNotification>", line 5, in structure_NotebookDocumentDidOpenNotification
    |     res['params'] = __c_structure_params(o['params'], __c_type_params)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "<cattrs generated structure lsprotocol.types.DidOpenNotebookDocumentParams>", line 14, in structure_DidOpenNotebookDocumentParams
    |     if errors: raise __c_cve('While structuring ' + 'DidOpenNotebookDocumentParams', errors, __cl)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    | cattrs.errors.ClassValidationError: While structuring DidOpenNotebookDocumentParams (1 sub-exception)
    | Structuring class NotebookDocumentDidOpenNotification @ attribute params
    +-+---------------- 1 ----------------
      | Exception Group Traceback (most recent call last):
      |   File "<cattrs generated structure lsprotocol.types.DidOpenNotebookDocumentParams>", line 5, in structure_DidOpenNotebookDocumentParams
      |     res['notebook_document'] = __c_structure_notebook_document(o['notebookDocument'], __c_type_notebook_document)
      |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |   File "<cattrs generated structure lsprotocol.types.NotebookDocument>", line 30, in structure_NotebookDocument
      |     if errors: raise __c_cve('While structuring ' + 'NotebookDocument', errors, __cl)
      |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      | cattrs.errors.ClassValidationError: While structuring NotebookDocument (2 sub-exceptions)
      | Structuring class DidOpenNotebookDocumentParams @ attribute notebook_document
      +-+---------------- 1 ----------------
        | Exception Group Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.NotebookDocument>", line 20, in structure_NotebookDocument
        |     res['cells'] = __c_structure_cells(o['cells'], __c_type_cells)
        |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 510, in _structure_list
        |     raise IterableValidationError(
        | cattrs.errors.IterableValidationError: While structuring typing.List[lsprotocol.types.NotebookCell] (1 sub-exception)
        | Structuring class NotebookDocument @ attribute cells
        +-+---------------- 1 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 502, in _structure_list
          |     res.append(handler(e, elem_type))
          |                ^^^^^^^^^^^^^^^^^^^^^
          |   File "<cattrs generated structure lsprotocol.types.NotebookCell>", line 26, in structure_NotebookCell
          |     if errors: raise __c_cve('While structuring ' + 'NotebookCell', errors, __cl)
          |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          | cattrs.errors.ClassValidationError: While structuring NotebookCell (1 sub-exception)
          | Structuring typing.List[lsprotocol.types.NotebookCell] @ index 0
          +-+---------------- 1 ----------------
            | Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.NotebookCell>", line 16, in structure_NotebookCell
            |     res['metadata'] = __c_structure_metadata(o['metadata'], __c_type_metadata)
            |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 574, in _structure_optional
            |     return self._structure_func.dispatch(other)(obj, other)
            |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 377, in _structure_error
            |     raise StructureHandlerNotFoundError(msg, type_=cl)
            | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: <class 'object'>. Register a structure hook for it.
            | Structuring class NotebookCell @ attribute metadata
            +------------------------------------
        +---------------- 2 ----------------
        | Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.NotebookDocument>", line 26, in structure_NotebookDocument
        |     res['metadata'] = __c_structure_metadata(o['metadata'], __c_type_metadata)
        |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 574, in _structure_optional
        |     return self._structure_func.dispatch(other)(obj, other)
        |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |   File "/var/home/alex/Projects/pygls/.env/lib64/python3.11/site-packages/cattrs/converters.py", line 377, in _structure_error
        |     raise StructureHandlerNotFoundError(msg, type_=cl)
        | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: <class 'object'>. Register a structure hook for it.
        | Structuring class NotebookDocument @ attribute metadata
        +------------------------------------

Can this be made to run in a container?

The python requirement is likely a dealbreaker for both dev machines and on CI. Makign this into a container would at least make it possible to run this without needing a developer's machine (esp. our 3rd party devs) to have python available. Thanks!

RecursionError calling get_converter() on Python 3.7.1

Hi folks. Thanks for this project! Excited to try out pygls 1.0 on top of lsprotocol.
I noticed the following RecursionError; not sure whether you want to try to work around it, or just bump the minimum supported version. (either is OK by me)

$ python
Python 3.7.1 (default, Dec 18 2022, 11:28:25) 
[Clang 11.0.3 (clang-1103.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lsprotocol.converters import get_converter
>>> get_converter()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/site-packages/lsprotocol/converters.py", line 17, in get_converter
    return _hooks.register_hooks(converter)
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/site-packages/lsprotocol/_hooks.py", line 35, in register_hooks
    _resolve_forward_references()
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/site-packages/lsprotocol/_hooks.py", line 30, in _resolve_forward_references
    attrs.resolve_types(value, lsp_types.ALL_TYPES_MAP, {})
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/site-packages/attr/_funcs.py", line 410, in resolve_types
    hints = typing.get_type_hints(cls, globalns=globalns, localns=localns)
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 973, in get_type_hints
    value = _eval_type(value, base_globals, localns)
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 262, in _eval_type
    ev_args = tuple(_eval_type(a, globalns, localns) for a in t.__args__)
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 262, in <genexpr>
    ev_args = tuple(_eval_type(a, globalns, localns) for a in t.__args__)
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 263, in _eval_type
    if ev_args == t.__args__:
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 658, in __eq__
    return frozenset(self.__args__) == frozenset(other.__args__)
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 664, in __hash__
  [... repeats many times ...]
  File "/Users/pschanely/.pyenv/versions/3.7.1/lib/python3.7/typing.py", line 477, in __hash__
    return hash((self.__forward_arg__, self.__forward_value__))
RecursionError: maximum recursion depth exceeded

Update LSP schema and model

LSP Schema has changed. Please update the generator.
Schema: source
Model: source

Instructions:

  1. Setup a virtual environment and install nox.
  2. Install all requirements for generator.
  3. Run nox --session update_lsp.

Hashes:

  • schema: 6a3119d483b7dcfe2e6d42dd2af945de1b7871c7238d846a97f6566d9811ae9c
  • model: 39e3cfda8ca814fac782d0ddb6e8bb534cd502322b5f6c653bc97bad4a5146a5

`lsprotocol` is too strict when parsing `CodeActionKind`?

During the process of aligning pytest-lsp to the 1.0 branch in pygls I've noticed that lsprotocol refuses to parse the client capabilities reported by any (currently released) version of neovim.

Specifically, when parsing the codeActionLiteralSupport field of CodeActionClientCapabilities

"codeActionLiteralSupport": {
  "codeActionKind": {
    "valueSet": [
      "",
      "Empty",
      "QuickFix",
      "Refactor",
      "RefactorExtract",
      "RefactorInline",
      "RefactorRewrite",
      "Source",
      "SourceOrganizeImports",
      "quickfix",
      "refactor",
      "refactor.extract",
      "refactor.inline",
      "refactor.rewrite",
      "source",
      "source.organizeImports"
    ]
  }
}

While the extra values are due to a bug (neovim/neovim#20678) that is now fixed upstream, until the fix is available in a released version anyone using neovim will not be able to use a pygls v1.0 powered language server.

Looking at the spec the set of CodeActionKinds is "open" so I'm wondering if the type definition for the valueSet field should be relaxed from List[CodeActionKind] to List[str]?

/**
 * The kind of a code action.
 *
 * Kinds are a hierarchical list of identifiers separated by `.`,
 * e.g. `"refactor.extract.function"`.
 *
 * The set of kinds is open and client needs to announce the kinds it supports
 * to the server during initialization.
 */
export type CodeActionKind = string;

/**
 * A set of predefined code action kinds.
 */
export namespace CodeActionKind {
  ...
}

I'm also wondering if you have any thoughts more generally on how a server could opt in to be more forgiving on the input it accepts?

Update LSP schema and model

LSP Schema has changed. Please update the generator.
Schema: source
Model: source

Instructions:

  1. Setup a virtual environment and install nox.
  2. Install all requirements for generator.
  3. Run nox --session update_lsp.

Hashes:

  • schema: 6a3119d483b7dcfe2e6d42dd2af945de1b7871c7238d846a97f6566d9811ae9c
  • model: 44fc784e14108c85c5f00d5e36e9cdbb39d8fd51d436077f3c34defe9c1e3d01

Use sentinel values for omittable fields

Some optional parameters are included in the json string of a attrs object when unstructured.

For example when we run the following code

import lsprotocol
from lsprotocol import converters

obj = lsprotocol.types.InitializeParams(
        capabilities=lsprotocol.types.ClientCapabilities(),
        process_id=1234,
        root_path='/file/path',
        workspace_folders=[lsprotocol.types.WorkspaceFolder(
            name='name',
            uri='file:///file/path/name'
        )]
    )

converter = converters.get_converter()

print(converter.unstructure(obj))

it outputs

{
    'capabilities': {},
    'processId': 1234,
    'rootPath': '/file/path',
    'rootUri': None,
    'workspaceFolders': [{'uri': 'file:///file/path/name', 'name': 'name'}]
}

Notice how rootUri has become None even though we didn't include it. I would expect that rootUri should not be included in the json representation since it is an optional (and in fact deprecated) parameter.

It's possible this is expected behavior and if so, is there someway to work around it? The lsp server I am working with (coqlsp) throws errors when some of the optional parameters are included as null and it would be great to not have to manually filter out all cases where this happens.

Missing structure hook for `CompletionItem.documentation`

I get the following error while trying to structure a CompletionItem that provides a documentation field

>>> converter.structure(dict(label='example', documentation='This is documented'), CompletionItem)
  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  |   File "/.../site-packages/cattrs/converters.py", line 309, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |   File "<cattrs generated structure lsprotocol.types.CompletionItem>", line 117, in structure_CompletionItem
  |     if errors: raise __c_cve('While structuring ' + 'CompletionItem', errors, __cl)
  | cattrs.errors.ClassValidationError: While structuring CompletionItem (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.CompletionItem>", line 35, in structure_CompletionItem
    |     res['documentation'] = __c_structure_documentation(o['documentation'], __c_type_documentation)
    |   File "/.../site-packages/cattrs/converters.py", line 377, in _structure_error
    |     raise StructureHandlerNotFoundError(msg, type_=cl)
    | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[str, lsprotocol.types.MarkupContent, NoneType]. Register a structure hook for it.
    | Structuring class CompletionItem @ attribute documentation
    +------------------------------------

Missing hook for optional FoldingRangeKind

| Traceback (most recent call last):
|   File "<cattrs generated structure lsprotocol.types.FoldingRange>", line 28, in structure_FoldingRange
|     res['kind'] = __c_structure_kind(o['kind'], __c_type_kind)
|   File "/home/streamer/Workspace/pygls/.tox/py/lib/python3.10/site-packages/cattrs/converters.py", line 377, in _structure_error
|     raise StructureHandlerNotFoundError(msg, type_=cl)
| cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[lsprotocol.types.FoldingRangeKind, str, NoneType]. Register a structure hook for it.
| Structuring class FoldingRange @ attribute kind

Ensure generator sets LSPObject = object

LSP model has its own definition of object that limits how we can work with objects in python.

LSPObject = Union[Dict[str, LSPAny]

We should override that and always set it to:

LSPObject = object

Using LSP definition of Object, breaks extensibility in libraries like pylgs and jedi-language-server which add custom protocol messages over LSP.

Issue with parsing SemanticTokensClientCapabilitiesRequestsType

Tried testing it with my current client (coc.nvim) and it breaks with the following deserialization message:

ERROR:pygls.protocol:Unable to deserialize message
  + Exception Group Traceback (most recent call last):
  |   File "/home/sroeca/src/Personal/jedi-language-server/.venv/lib/python3.10/site-packages/pygls/protocol.py", line 347, in _deserialize_message
  |     return converter.structure(data, request_type)
  |   File "/home/sroeca/src/Personal/jedi-language-server/.venv/lib/python3.10/site-packages/cattrs/converters.py", line 309, in structure
  |     return self._structure_func.dispatch(cl)(obj, cl)
  |   File "<cattrs generated structure lsprotocol.types.InitializeRequest>", line 26, in structure_InitializeRequest
  |     if errors: raise __c_cve('While structuring ' + 'InitializeRequest', errors, __cl)
  | cattrs.errors.ClassValidationError: While structuring InitializeRequest (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception Group Traceback (most recent call last):
    |   File "<cattrs generated structure lsprotocol.types.InitializeRequest>", line 10, in structure_InitializeRequest
    |     res['params'] = __c_structure_params(o['params'], __c_type_params)
    |   File "<cattrs generated structure lsprotocol.types.InitializeParams>", line 63, in structure_InitializeParams
    |     if errors: raise __c_cve('While structuring ' + 'InitializeParams', errors, __cl)
    | cattrs.errors.ClassValidationError: While structuring InitializeParams (1 sub-exception)
    | Structuring class InitializeRequest @ attribute params
    +-+---------------- 1 ----------------
      | Exception Group Traceback (most recent call last):
      |   File "<cattrs generated structure lsprotocol.types.InitializeParams>", line 5, in structure_InitializeParams
      |     res['capabilities'] = __c_structure_capabilities(o['capabilities'], __c_type_capabilities)
      |   File "<cattrs generated structure lsprotocol.types.ClientCapabilities>", line 40, in structure_ClientCapabilities
      |     if errors: raise __c_cve('While structuring ' + 'ClientCapabilities', errors, __cl)
      | cattrs.errors.ClassValidationError: While structuring ClientCapabilities (1 sub-exception)
      | Structuring class InitializeParams @ attribute capabilities
      +-+---------------- 1 ----------------
        | Exception Group Traceback (most recent call last):
        |   File "<cattrs generated structure lsprotocol.types.ClientCapabilities>", line 12, in structure_ClientCapabilities
        |     res['text_document'] = __c_structure_text_document(o['textDocument'], __c_type_text_document)
        |   File "/home/sroeca/src/Personal/jedi-language-server/.venv/lib/python3.10/site-packages/cattrs/converters.py", line 574, in _structure_optional
        |     return self._structure_func.dispatch(other)(obj, other)
        |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 184, in structure_TextDocumentClientCapabilities
        |     if errors: raise __c_cve('While structuring ' + 'TextDocumentClientCapabilities', errors, __cl)
        | cattrs.errors.ClassValidationError: While structuring TextDocumentClientCapabilities (1 sub-exception)
        | Structuring class ClientCapabilities @ attribute text_document
        +-+---------------- 1 ----------------
          | Exception Group Traceback (most recent call last):
          |   File "<cattrs generated structure lsprotocol.types.TextDocumentClientCapabilities>", line 144, in structure_TextDocumentClientCapabilities
          |     res['semantic_tokens'] = __c_structure_semantic_tokens(o['semanticTokens'], __c_type_semantic_tokens)
          |   File "/home/sroeca/src/Personal/jedi-language-server/.venv/lib/python3.10/site-packages/cattrs/converters.py", line 574, in _structure_optional
          |     return self._structure_func.dispatch(other)(obj, other)
          |   File "<cattrs generated structure lsprotocol.types.SemanticTokensClientCapabilities>", line 54, in structure_SemanticTokensClientCapabilities
          |     if errors: raise __c_cve('While structuring ' + 'SemanticTokensClientCapabilities', errors, __cl)
          | cattrs.errors.ClassValidationError: While structuring SemanticTokensClientCapabilities (1 sub-exception)
          | Structuring class TextDocumentClientCapabilities @ attribute semantic_tokens
          +-+---------------- 1 ----------------
            | Exception Group Traceback (most recent call last):
            |   File "<cattrs generated structure lsprotocol.types.SemanticTokensClientCapabilities>", line 5, in structure_SemanticTokensClientCapabilities
            |     res['requests'] = __c_structure_requests(o['requests'], __c_type_requests)
            |   File "<cattrs generated structure lsprotocol.types.SemanticTokensClientCapabilitiesRequestsType>", line 16, in structure_SemanticTokensClientCapabilitiesRequestsType
            |     if errors: raise __c_cve('While structuring ' + 'SemanticTokensClientCapabilitiesRequestsType', errors, __cl)
            | cattrs.errors.ClassValidationError: While structuring SemanticTokensClientCapabilitiesRequestsType (1 sub-exception)
            | Structuring class SemanticTokensClientCapabilities @ attribute requests
            +-+---------------- 1 ----------------
              | Traceback (most recent call last):
              |   File "<cattrs generated structure lsprotocol.types.SemanticTokensClientCapabilitiesRequestsType>", line 12, in structure_SemanticTokensClientCapabilitiesRequestsType
              |     res['full'] = __c_structure_full(o['full'], __c_type_full)
              |   File "/home/sroeca/src/Personal/jedi-language-server/.venv/lib/python3.10/site-packages/cattrs/converters.py", line 377, in _structure_error
              |     raise StructureHandlerNotFoundError(msg, type_=cl)
              | cattrs.errors.StructureHandlerNotFoundError: Unsupported type: typing.Union[bool, lsprotocol.types.SemanticTokensClientCapabilitiesRequestsTypeFullType1, NoneType]. Register a structure hook for it.
              | Structuring class SemanticTokensClientCapabilitiesRequestsType @ attribute full
              +------------------------------------

Validation of this breaks:

[Trace - 12:05:09 PM] Sending request 'initialize - (0)'.
Params: {
    "processId": 1105947,
    "rootPath": "/home/sroeca/src/Personal/jedi-language-server",
    "rootUri": "file:///home/sroeca/src/Personal/jedi-language-server",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "undo",
                "normalizesLineEndings": true,
                "changeAnnotationSupport": {
                    "groupsOnLabel": false
                }
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true,
                "relativePatternSupport": true
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            },
            "semanticTokens": {
                "refreshSupport": true
            },
            "inlayHint": {
                "refreshSupport": true
            },
            "inlineValue": {
                "refreshSupport": true
            },
            "diagnostics": {
                "refreshSupport": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "resolveSupport": {
                    "properties": [
                        "location.range"
                    ]
                }
            },
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true,
                "versionSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1,
                        2
                    ]
                },
                "codeDescriptionSupport": true,
                "dataSupport": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true,
                    "insertReplaceSupport": true,
                    "tagSupport": {
                        "valueSet": [
                            1
                        ]
                    },
                    "resolveSupport": {
                        "properties": [
                            "documentation",
                            "detail",
                            "additionalTextEdits"
                        ]
                    },
                    "labelDetailsSupport": true,
                    "insertTextModeSupport": {
                        "valueSet": [
                            1,
                            2
                        ]
                    }
                },
                "completionItemKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25
                    ]
                },
                "insertTextMode": 2,
                "completionList": {
                    "itemDefaults": [
                        "commitCharacters",
                        "editRange",
                        "insertTextFormat",
                        "insertTextMode"
                    ]
                }
            },
            "hover": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "activeParameterSupport": true,
                    "parameterInformation": {
                        "labelOffsetSupport": true
                    }
                }
            },
            "references": {
                "dynamicRegistration": true
            },
            "definition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "valueSet": [
                        1,
                        2,
                        3,
                        4,
                        5,
                        6,
                        7,
                        8,
                        9,
                        10,
                        11,
                        12,
                        13,
                        14,
                        15,
                        16,
                        17,
                        18,
                        19,
                        20,
                        21,
                        22,
                        23,
                        24,
                        25,
                        26
                    ]
                },
                "hierarchicalDocumentSymbolSupport": true,
                "tagSupport": {
                    "valueSet": [
                        1
                    ]
                },
                "labelSupport": true
            },
            "codeAction": {
                "dynamicRegistration": true,
                "isPreferredSupport": true,
                "disabledSupport": true,
                "dataSupport": true,
                "honorsChangeAnnotations": false,
                "resolveSupport": {
                    "properties": [
                        "edit"
                    ]
                },
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true,
                "prepareSupport": true,
                "honorsChangeAnnotations": true,
                "prepareSupportDefaultBehavior": 1
            },
            "documentLink": {
                "dynamicRegistration": true,
                "tooltipSupport": true
            },
            "typeDefinition": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "implementation": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "declaration": {
                "dynamicRegistration": true,
                "linkSupport": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            },
            "foldingRange": {
                "dynamicRegistration": true,
                "rangeLimit": 5000,
                "lineFoldingOnly": true,
                "foldingRangeKind": {
                    "valueSet": [
                        "comment",
                        "imports",
                        "region"
                    ]
                },
                "foldingRange": {
                    "collapsedText": false
                }
            },
            "selectionRange": {
                "dynamicRegistration": true
            },
            "callHierarchy": {
                "dynamicRegistration": true
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            },
            "semanticTokens": {
                "dynamicRegistration": true,
                "tokenTypes": [
                    "namespace",
                    "type",
                    "class",
                    "enum",
                    "interface",
                    "struct",
                    "typeParameter",
                    "parameter",
                    "variable",
                    "property",
                    "enumMember",
                    "event",
                    "function",
                    "method",
                    "macro",
                    "keyword",
                    "modifier",
                    "comment",
                    "string",
                    "number",
                    "regexp",
                    "decorator",
                    "operator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false,
                "serverCancelSupport": true,
                "augmentsSyntaxTokens": true
            },
            "inlayHint": {
                "dynamicRegistration": true,
                "resolveSupport": {
                    "properties": [
                        "tooltip",
                        "textEdits",
                        "label.tooltip",
                        "label.location",
                        "label.command"
                    ]
                }
            },
            "inlineValue": {
                "dynamicRegistration": true
            },
            "diagnostic": {
                "dynamicRegistration": true,
                "relatedDocumentSupport": true
            },
            "typeHierarchy": {
                "dynamicRegistration": true
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "4.0.10"
            },
            "positionEncodings": [
                "utf-16"
            ],
            "staleRequestSupport": {
                "cancel": true,
                "retryOnContentModified": [
                    "textDocument/inlayHint",
                    "textDocument/semanticTokens/full",
                    "textDocument/semanticTokens/range",
                    "textDocument/semanticTokens/full/delta"
                ]
            }
        }
    },
    "initializationOptions": {
        "enable": true,
        "startupMessage": false,
        "trace": {
            "server": "verbose"
        },
        "jediSettings": {
            "autoImportModules": [
                "pygls"
            ],
            "caseInsensitiveCompletion": true,
            "debug": false
        },
        "executable": {
            "args": [],
            "command": "jedi-language-server"
        },
        "codeAction": {
            "nameExtractFunction": "jls_extract_def",
            "nameExtractVariable": "jls_extract_var"
        },
        "completion": {
            "disableSnippets": false,
            "resolveEagerly": false,
            "ignorePatterns": []
        },
        "diagnostics": {
            "enable": true,
            "didOpen": true,
            "didChange": true,
            "didSave": true
        },
        "hover": {
            "enable": true,
            "disable": {
                "class": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "function": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "instance": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "keyword": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "module": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "param": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "path": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "property": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                },
                "statement": {
                    "all": false,
                    "names": [],
                    "fullNames": []
                }
            }
        },
        "workspace": {
            "extraPaths": [],
            "symbols": {
                "maxSymbols": 20,
                "ignoreFolders": [
                    ".nox",
                    ".tox",
                    ".venv",
                    "__pycache__",
                    "venv"
                ]
            }
        }
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///home/sroeca/src/Personal/jedi-language-server",
            "name": "jedi-language-server"
        }
    ],
    "locale": "en_US",
    "clientInfo": {
        "name": "coc.nvim",
        "version": "0.0.82"
    }
}

Originally posted by @pappasam in pappasam/jedi-language-server#230 (comment)

Update LSP schema and model

LSP Schema has changed. Please update the generator.
Schema: source
Model: source

Instructions:

  1. Setup a virtual environment and install nox.
  2. Install all requirements for generator.
  3. Run nox --session update_lsp.

Hashes:

  • schema: 6a3119d483b7dcfe2e6d42dd2af945de1b7871c7238d846a97f6566d9811ae9c
  • model: 3ab804f7aa4511cd626c6660c4ce9bf82dbb3b5ab8d405ea8969937de64be9ee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.