From 95f3807b4a1926c9364d1f0b2fa2ed8bec86cf5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Mon, 23 Jan 2023 14:03:03 +0100 Subject: [PATCH] Only pass the id parameter to types that use it This fixes https://github.com/openlawlibrary/pygls/issues/312 --- pygls/protocol.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pygls/protocol.py b/pygls/protocol.py index 4f0d012d..1dba0737 100644 --- a/pygls/protocol.py +++ b/pygls/protocol.py @@ -581,12 +581,10 @@ def send_request(self, method, params=None, callback=None, msg_id=None): request_type = self.get_message_type(method) or JsonRPCRequestMessage logger.debug('Sending request with id "%s": %s %s', msg_id, method, params) - request = request_type( - id=msg_id, - method=method, - params=params, - jsonrpc=JsonRPCProtocol.VERSION, - ) + kwargs = {"method": method, "params": params, "jsonrpc": JsonRPCProtocol.VERSION} + if hasattr(request_type, "id"): + kwargs["id"] = msg_id + request = request_type(**kwargs) future = Future() # If callback function is given, call it when result is received