microsoft / lsprotocol

Code generator and generated types for Language Server Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate type aliases for result types?

alcarney opened this issue · comments

Currently, to write a function that handles the result of a textDocument/completion request, you need to look up and write the following type annotation

from lsprotocol import types

def handle_result(result: Union[List[types.CompletionItem], types.CompletionList, None]):
    ...

It looks like lsprotocol already generates some type aliases e.g. DocumentDiagnosticReport - would it be possible to extend this to cover all result types (where relevant) so that you would only have to write

from lsprotocol import types

def handle_result(result: types.CompletionResult):
    ...