-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling notification/request parameters that is not used for class fields name from the server #56
Conversation
dummy
from the serverUpdate CONTRIBUTORS.md
@tom-tan Good catch and thank you for your contribution! Maybe we should consider adding multiple clients for our json-extension example, because we are testing it just with VS Code. P.S. Check-boxes in Code review checklist from the PR template should be checked by a code reviewer, so I will uncheck them. |
pygls/protocol.py
Outdated
@@ -83,7 +83,7 @@ def deserialize_message(data): | |||
return JsonRPCNotification(**data) | |||
|
|||
return namedtuple('Object', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tom-tan Can you please remove the line break? Line 85. won't be longer than 79 chars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel comfortable, it would be great to add some tests for deserialize_message
to test_protocol.py. No worries if you can't, just let me know, so I can merge the PR otherwise.
Thank you for your suggestion. I will update the code and add a test for it. |
Done! I added a test for |
Looks go to me. @tom-tan Can you please update the CHANGELOG file? We decided that every notable changes should be added to the CHANGELOG, and I think that this PR's change should be recorded there. To make it easier for you, here is how it should look:
EDIT: Corrected PR link in example changelog. |
Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tom-tan Looks go to me, will merge it soon.
Thank you again for your contribution! Let us know about your experience with pygls and if you have any language server that is based on it, feel free to update Implementations document. :)
''' | ||
obj = json.loads(params_with_reserved_word, | ||
object_hook=deserialize_message) | ||
assert isinstance(obj, object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Python, this is True for every valid first argument.
Sorry, I accidentally send incomplete request...
I will update it to make this request complete.
Description (e.g. "Related to ...", etc.)
This request is to handle message fields that is not valid as python class fields (such as
__dummy__
) from the client.For example, Eglot, which is a LSP client for emacs send
initialized
notification with__dummy__
parameter.Currently language servers that are based on pygls fail with the following exception message:
The reason is that
__dummy__
that is sent from Eglot is not valid identifier for the field name in python.By using
rename=True
fornamedtuple
, such fields are replaced with_1
,_2
and so on.Their names are very annoying but is better than server terminations.
Note:
cwl_language_server
is our project for a language server for Common Workflow Language.We currently use pylspclient but we start trying pygls as an alternative.
Code review checklist (for code reviewer to complete)