-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Change in behavior in how diagnostic squiggle is shown between v1.61 and 1.62+ #142810
Comments
Same issue on MacOS but hovering the code does not show any tooltip at all. Downgrading VsCode to 1.61.2 (Universal) solves the issue Working version |
yeah there's like a 1 pixel hitbox for the tooltip to appear, it's driving me nuts |
This happened to me as well, only started recently. If anyone has any tips on settings that can be changed to work around this, please post! I have to look at the PROBLEMS section of the bottom window to see the mypy errors now. The linting output looks OK to me, in the OUTPUT section:
|
Hi, here is a workaround: By default, vscode sets the the following {
// pylint
"python.linting.pylintCategorySeverity.convention": "Information",
"python.linting.pylintCategorySeverity.error": "Error",
"python.linting.pylintCategorySeverity.fatal": "Error",
"python.linting.pylintCategorySeverity.refactor": "Hint",
"python.linting.pylintCategorySeverity.warning": "Warning",
// flake8
"python.linting.flake8CategorySeverity.E": "Error",
"python.linting.flake8CategorySeverity.F": "Error",
"python.linting.flake8CategorySeverity.W": "Warning",
// mypy
"python.linting.mypyCategorySeverity.error": "Error",
"python.linting.mypyCategorySeverity.note": "Information",
// pycodestyle
"python.linting.pycodestyleCategorySeverity.E": "Error",
"python.linting.pycodestyleCategorySeverity.W": "Warning",
} I've noticed that only the Also, if you work with Since everything would be considered to be a {
// pylint
"python.linting.pylintCategorySeverity.convention": "Hint",
"python.linting.pylintCategorySeverity.error": "Hint",
"python.linting.pylintCategorySeverity.fatal": "Hint",
"python.linting.pylintCategorySeverity.refactor": "Hint",
"python.linting.pylintCategorySeverity.warning": "Hint",
// flake8
"python.linting.flake8CategorySeverity.A": "Hint",
"python.linting.flake8CategorySeverity.B": "Hint",
"python.linting.flake8CategorySeverity.C": "Hint",
"python.linting.flake8CategorySeverity.D": "Hint",
"python.linting.flake8CategorySeverity.E": "Hint",
"python.linting.flake8CategorySeverity.F": "Hint",
"python.linting.flake8CategorySeverity.G": "Hint",
"python.linting.flake8CategorySeverity.H": "Hint",
"python.linting.flake8CategorySeverity.I": "Hint",
"python.linting.flake8CategorySeverity.J": "Hint",
"python.linting.flake8CategorySeverity.K": "Hint",
"python.linting.flake8CategorySeverity.L": "Hint",
"python.linting.flake8CategorySeverity.M": "Hint",
"python.linting.flake8CategorySeverity.N": "Hint",
"python.linting.flake8CategorySeverity.O": "Hint",
"python.linting.flake8CategorySeverity.P": "Hint",
"python.linting.flake8CategorySeverity.Q": "Hint",
"python.linting.flake8CategorySeverity.R": "Hint",
"python.linting.flake8CategorySeverity.S": "Hint",
"python.linting.flake8CategorySeverity.T": "Hint",
"python.linting.flake8CategorySeverity.U": "Hint",
"python.linting.flake8CategorySeverity.V": "Hint",
"python.linting.flake8CategorySeverity.W": "Hint",
"python.linting.flake8CategorySeverity.X": "Hint",
"python.linting.flake8CategorySeverity.Y": "Hint",
"python.linting.flake8CategorySeverity.Z": "Hint",
// mypy
"python.linting.mypyCategorySeverity.error": "Hint",
"python.linting.mypyCategorySeverity.note": "Hint",
// pycodestyle
"python.linting.pycodestyleCategorySeverity.E": "Hint",
"python.linting.pycodestyleCategorySeverity.W": "Hint",
}
|
thank you @diegovalenzuelaiturra ... very useful info! losing them all in |
This has been addressed in |
Still not fixed in
|
As expected. The issue is targeted for |
@cdce8p As per discussion on the issue you've linked, the only thing that was fixed is the mouse-over hitbox of the underlined character - it's not one pixel wide anymore, but rather actually covers the single character that's underlined. Still, with the hitbox issue fixed, the issue where it underlines only one character (instead of the whole word like before) still persists. |
This bug is still present in the latest version |
Version vscode:
|
Is it going to be ever fixed? This is super annoying bug, I'm so surprised there's not that much noise around it from what I can see here. It's been going on for 3 months now! The python code with just one character underscored for errors coming from linters (like was shown on the screenshots on the original report) is very hard to work with! @alexdima any chance yourself or someone else from the team can look into it, please? |
Sorry for the delayed response on this. somehow this got missed. I looks at the diagnostic object that we generate. we have not changed how we do this for over three years. The output from
The diagnostic object for this case looks like this: {
"severity":"Error","message":"Argument 1 to \"foo\" has incompatible type \"str\"; expected \"int\"",
"range":{
"start"{"line":3,"character":4},
"end": {"line":3,"character":4}
},
"source":"mypy",
"code":"error"
} In the older version of VS Code this used to put the squiggle under the whole word. Transferring this to VS Code for further investigation. |
Repro steps:
def foo(value:int):
pass
foo("abcde")
Ensure that you have python extension activated, for this example you will need to install |
You're right, I forgot about this change. The editor used to artificially expand zero width diagnostics (empty ranges) on the word next to the diagnostic. I changed this for #66482 where there were examples where expanding to the word next to the diagnostic is not desirable (e.g. missing semicolon at end of line). |
This reverts commit e0dbcb2. This commit is no longer needed because the upstream bug is fixed, see: microsoft/vscode#142810
@joyceerhl I can reproduce what you are seeing in So @karthiknadig I believe that at least 2 distinct things have changed in the same time-frame:
Here are new verification steps that are independent of
{
"name": "142810",
"version": "0.0.1",
"publisher": "alex",
"engines": { "vscode": "^1.34.0" },
"activationEvents": [ "*" ],
"main": "main.js"
}
const vscode = require('vscode');
exports.activate = function() {
const collection = vscode.languages.createDiagnosticCollection('142810');
collection.set(vscode.window.activeTextEditor.document.uri, [
new vscode.Diagnostic(new vscode.Range(0,5,0,5), 'some error 1'),
new vscode.Diagnostic(new vscode.Range(1,5,1,5), 'some error 2'),
new vscode.Diagnostic(new vscode.Range(2,5,2,5), 'some error 3'),
new vscode.Diagnostic(new vscode.Range(3,5,3,5), 'some error 4'),
new vscode.Diagnostic(new vscode.Range(4,5,4,5), 'some error 5'),
])
};
something - in the middle of a word
!@#$%^& - in the middle of non-word chars
hello
hellos
Please reload insiders with the
|
@alexdima This is the diagnostic object we get back after parsing
For this code: def foo(v:int):
pass
foo("something") I believe since the diagnostic is falling on |
@karthiknadig Then this issue was always there, because the current behavior matches that of 1.61. If a zero-width error lands in a non-word character, it is rendered with the width of 1ch. You can also try 1.61 or older versions of VS Code using the download links at the top e.g. https://code.visualstudio.com/updates/v1_61 |
@karthiknadig At this point, VSCode has "fixed" the issue on this side, which ultimately ends up in a breaking change. Now it's time for the Python extension to alter how the MyPy and Flake8 output is parsed, so that the "parsed diagnostic object" you get will actually span the entire argument. Given your example code as def foo(v:int):
pass
foo("something") ..., this is the raw MyPy output (with
..., which should result in a diagnostic object along the lines of:
Note that I've included the exact range here. Alternatively, the existing solution with the Also, I've installed And the same from I even tried |
@DevilXD where is the end part of the range coming from? From the raw output that you have from mypy I see the start 4:5 but not the end range. Without the tool telling us the exact range, how do we know where to stop?
I don't see how we can take this (without knowing what exact issue that the linter might be talking about) and translate it to range 4:5 and 4:15. What if the linter as complaining about the type of quote (literal character) that was used vs the entire string. If we squiggle the entire string it might be wrong. For the best experience here we need the range from the tool. An interim solution could be:
@alexdima I feel Option 1 might be something we could do now. If that is not the route we want to take, then the next best option is [option 3] for the individual linting extensions to be ready. If you have another recommendation, let me know. Neiter of the above options provide the best experience, ideally this range should come from the tools themselves. /cc @luabud @brettcannon |
Yes, this is the part where I'm not familiar with how the internals of the extension work, so it'd be "up to figure out". I can see that you've already listed several options, neither of which are trivial. What about the shifting approach then? Still using the 0-width range, but placing it 1 character further to the right, so that it lands on the initial |
@karthiknadig Adding a special case for
I suggest that either the extension which can understand the underlying python syntax tries to massage the error or otherwise I suggest that you reach out to the maintainers of |
@moto-ctrl Regarding pylint. We recently added support for error ranges. Those aren't perfect yet, but we (the pylint team) are working on improving them for the next release. Please take a look at pylint-dev/pylint#5466 Like others have mentioned already, this is different to |
ah I see, so the old version of vscode didn't understand ranges therefore even with latest pylint it still just highlights only the first word (def in this case) whereas new vscode parses ranges and the highlight of the whole function comes from the pylint itself - which is being discussed in the issue you linked. Thanks for clarifying that. |
Correct, we had to add range support to pylint first, after which I contributed a patch to the VSC Python to actually use them.
We, the pylint team, would appreciate feedback about specific issues with ranges (in the pylint repo). Probably best after the next update though since that will already address a lot of issues. Another point, I've seen discussions about custom language server extensions for Python linters the VSC Python team is working on. A switch to select positions or ranges for highlighting might be a good suggestion. |
And something else occurred to me - sorry this was perhaps obvious but I'll write it down for benefit of everyone
Here's my example with mypy and flake8 (switched off pylint to get better picture) |
so as this is issue is still not resolved in 1.65, can it be re-opened and transferred back to the vscode-python repo? or should i re-raise it there? |
@DetachHead I think this issue is addressed from VS Code. There are now two issues:
|
VS Code version
1.62.1
Extension version
2021.11.1422169775
OS type
Windows
OS version
10
Python distribution
python.org
Python version
3.10
Language server
Pylance
Expected behaviour
Actual behaviour
Steps to reproduce
settings.json
:Logs
Code of Conduct
The text was updated successfully, but these errors were encountered: