-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for pylint error ranges #18068
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
Conversation
Hi @cdce8p, thank you for the PR! We're currently discussing this with the team: Ideally we would like to have dynamic support for error ranges without having to rely on a setting, but that would require a pylint version check. Since our current support isn't stateful we would have to perform that check for every run of pylint, which is something we want to avoid. |
@kimadeline Thanks for the reply. I though that this would be the case as I don't like too much either. I'll need to check tomorrow but there could be another option. Pylint does have some alternative report options, in particular the builtin json-reporter, that might not have this issue. If that doesn't work, it would be possible to add a custom one as plugin that is backwards compatible. You would then only need to make sure that it's installed in the environment, similar to the requirements for jupyter notebook. It won't be much help for this PR, but we fixed the backwards incompatibility issue with |
@cdce8p sorry for the delayed reply; I wrote out an entire reply and I though It clicked "Comment", but it isn't here so I must have forgotten to post it. 😬 The key thing is we are looking to rewrite out Pylint support in hopefully the next couple of months. As such, we don't want to add another setting that we won't need in a little bit (as we can handle this transparently with the rewrite as we will be putting Pylint behind LSP). But if you wanted to do the work to move our support over to the JSON reporter and see if that can be used to transparently support the new range feature then we can have a look at the PR. |
I've updated the PR to parse the JSON output for pylint. The pylint PR to add There is a slight caveat, the json output doesn't include a score. Some users might miss it. IMO though, the benefit of having error ranges far outweigh this. Especially considering that the score for a single file isn't all that useful. In case this is accepted, we, from the pylint team, would love it if these changes could be included in the next release. Please let me know if I can help make that happen. Update |
Unfortunately the cut-off for features for the next release passed on Monday, so if we accept this it would come out in our 2022.2 release which would be the first Wednesday/Thursday of February. |
@brettcannon Thanks for letting me know. I understand. I had hoped the cutoff would be next week 😞 |
@cdce8p you can always look up when our feature freeze is by looking at our latest release plan. The one for the release going out this week is #18003. |
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.
Thank you for amending your PR @cdce8p!
It looks good to me. I left a few linting and nitpicky comments here and there, and we should be good to merge it afterwards.
@kimadeline Thanks for the review! I've updated the PR and left some comments on open questions. |
@cdce8p the venv failures are probably due to VS Code 1.63.0 going out (our tests can be rather sensitive around file watching and that got an update in this release). |
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.
Thank you for your contribution, and for the quick turnaround!
As Brett pointed out, the test failures are not caused by your PR, so I'm going to go ahead and merge it.
Adding the highlighting only for selected messages is probably something that VSCode would need to implement. However, you'll be happy to know that we're planning on changing the ranges for class and function definitions in the next version of For those who are interested, we would welcome a PR that targets this exact issue! |
Do you know if VSCode uses the class/function definition or uses this |
No, VSCode only parses the output generated by
See L50 in So if VSCode was ever to change this I think it would only be possible on a per-message basis, without this becoming too complicated. |
You can always make a proposal/issue in The "message ranges" are defined when we call |
Thanks, do you recommend I open an issue specific to the Class/function docstring ranges or leave it as it's already mentioned in pylint-dev/pylint#5466? Would it make sense to have I've read the |
If it's only about those I think the current issue is good enough.
I'm not sure what the best approach is here (and I think this discussion should continue in the |
I just wanted to quickly thank @DanielNoord for popping over and helping out with the discussion! |
* Add support for pylint error ranges * Remove pylintErrorRangeEnabled setting * Revert changes to base linter * Parse json output - pylint * Fix existing tests * Add news entry * Fix small issues * Add additional test cases * Formatting * Update news entry to include Python requirement * Address comments from code review * Fix tests after upstream merge * Trigger CI
With the next pylint release
2.12.0
(hopefully this weekend), we are adding support for error ranges. I.e.end_line
andend_column
information for error messages. Tracking issue: pylint-dev/pylint#5336This PRs adds support for those to allow for better error highlighting when using
pylint
in VSCode.Before I continuing to work on it, I wanted to see if there is interest in adding this to
vscode-python
and if the approach is the correct one.Related: #18027
--
Background
Starting with
2.12.0
, the--msg-template
option will accept two new parametersend_line
andend_column
. Both return either anint
(from the AST) or an empty string (if unknown). Unfortunately, we are unable to make this option backwards compatible due to the way it was implemented many years ago. Addingend_line
to--msg-template
in versions prior to2.12.0
will raise aKeyError
.