-
-
Notifications
You must be signed in to change notification settings - Fork 104
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: True LSP Diagnostic param, with version
#303
Conversation
1a569a5
to
244a9df
Compare
Looks good... though I'm not sure why we need to deprecate the old signature, can't it just be extended with an optional Also don't forget your changelog entry :) |
Agree |
244a9df
to
2282d4a
Compare
Oh, so you both don't think we should deprecate the old signature. I'm a bit confused by that because the only argument I can think of for not starting the process of a new signature is that maintaining the current signature is just less effort. I think there are 2 good reasons for changing.
BTW, this PR gives us both signatures. So there's no breaking change yet. Users can easily get rid of the warning log and benefit from automatic future compatibility, by using the new signature. |
I suppose my resistance to moving from the old signature is more of a stylistic argument than a technical one. While the new signature is a win for maintainability, I'd argue it's a step back for usability - with my server.publish_diagnostics("file:///...", [...], version=1) over params = PublishDiagnosticsParams(uri="file:///...", diagnostics=[...], version=1)
server.publish_diagnostics(params) It should be possible to update the existing signature and still make it future proof def publish_diagnostics(self, uri: str, diagnostics: List[Diagnostic], version: Optional[int] = None, **kwargs):
params = PublishDiagnosticsParams(
uri=uri,
diagnostics=diagnostics,
version=version,
**kwargs
)
self.lsp.publish_diagnostics(params) Yes, it's a little bit of extra maintenance for us to add in new fields to aid with discoverability, but at least no one is prevented from using the new fields as soon as they're available.
Perhaps we can use this PR to decide what we want the answer to be? I'd argue the answer should be your assumption
Where the Looking at |
I only know the python jedi language server and they use server.py calls, I guess for that reason. My solution to this issue is along your lines, simple, and backward compatible. But there is a half way house which I think is preferable. The signature at server.py stays the same (with optional version added), but the signature at protocol.py changes to PublishDiagnosticsParams. So users have a choice to use either. Future-proofing is probaly not an issue. Microsoft is unlike to break what works now. They may be adding stuff but it will be backward compatible and could be accommodated, if and when necessary. |
2282d4a
to
d288721
Compare
Ok, I've pushed a change, that incorporates both your ideas. Thank you. I still don't agree about the utility of having simpler An nice idea @alcarney, I've made a new issue to explore finding parity between server and protocol: #306 |
68da1ec
to
e9f7271
Compare
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.
Apologies for the delay, hopefully you've all had / are enjoying the holiday break!
I made a comment, but up to you on whether you want to act on it or not.
pygls/server.py
Outdated
""" | ||
Sends diagnostic notification to the client. | ||
""" | ||
self.lsp.publish_diagnostics(uri, diagnostics, version, **kwargs) |
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.
Just a thought.
It might make sense to have this method construct and pass a PublishDiagnosticsParams
object, so that the user doesn't see a deprecation warning on what appears to be an internal function.
But perhaps that can wait until we decide on #306
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.
This is a really good point. I've just force-pushed this. Is it what you meant?
(Apologies for the delay too! I'm in South America at the moment so it was hooooot holiday season 🥵 hahah)
bdf97d9
to
358a01b
Compare
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.
Looks good :)
Fixes #211 Includes deprecation warning for old method signature
358a01b
to
e8a6a56
Compare
Thanks :) That docs PR triggered a conflict, so need a re-review 😬 |
Released in https://pypi.org/project/pygls/1.0.1 |
Fixes #211
Includes deprecation warning for old method signature
I don't know if I'm being too clever here?
Also, does anybody know why there are often 2 public methods to do the same thing like this? Therefore, we can call both
pygls.server.LanguageServer.publish_diagnostics
andpygls.protocol.LanguageServerProtocol.publish_diagnostics
. I assume it's becausepygls.server.LanguageServer
is the more friendly user-facing class, whilstpygls.protocol.LanguageServerProtocol
is internal and has to be comprehensive.Code review checklist (for code reviewer to complete)