Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Code action to add/delete imports #685
base: develop
Are you sure you want to change the base?
Code action to add/delete imports #685
Changes from 16 commits
e7e7dd2
f9ef0a0
4c89036
4383f1e
7ed8a3b
4ae20c8
8242066
5175028
f54910d
2668de3
ecabe85
936f121
b0f04a3
2261042
d57d904
c7e5b36
061f0cc
e9996f7
48d1f01
2d12e54
71b8385
f99d33e
6812993
d178670
ae63149
a712a73
80def3f
0a9d163
e7ee0ca
809a4af
1c509f9
b82ff8f
107c431
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Let's make this return a future, that way we can skip results instead of blocking on indexing.
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.
Should this not be a warning / error? Or does it overlap with e.g. pyflakes results
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 hint because we actually don't know if this is a module to be imported or just a non defined variable, so better not to trigger a false positive. The unreferenced symbols are flagged with Warning because we know in advance if the symbol is either an import or a varialbe/function and the error should be consistent.
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.
I wonder if it's easier to just call
pyls_lint(document)
, then try to find the context diagnostic in the results. That way we don't have to parse the messages, just have to do an equality check.e.g.
action_diags = [diag for diag in pyls_lint(document) if diag in context.get('diagnostics', [])]
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.
True that the diagnostics list can grow bigger than the local diagnostics and we will just pass most of them. Also we don't need to do the equality check if we call pyls_lint() as all the diagnostics will be processed.
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.
I think newer versions of clients support putting the edit in the code action:
But I'm not sure which client capability we should check. What you've got now is probably safer