-
Notifications
You must be signed in to change notification settings - Fork 46
Improve errors and output handling #59
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
package.json
Outdated
| "scope": "resource", | ||
| "type": "array" | ||
| }, | ||
| "black-formatter.show-formatting-messages": { |
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.
@luabud Can you look at the naming of this setting and description for this? This setting allows users to get a visible UI notification if there is a issue when formatting. We also need to decide on the default value for this setting.
I feel like this should be a enum, with values like never, on-error, and on-warn. on-error covers scenarios where formatting fails due to some error like syntax error, or out-of-date version etc. on-warn covers scenarios in the on-error plus cases where formatting is intentionally skipped.
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 love the enum idea, and I don't see a problem with the setting name as is, but something more descriptive that this would show a notification could also work (e.g. black-formatter.promptMessages).
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.
May be black-formatter.showNotification? so that "black-formatter.showNotification": "on-warn" makes more sense as to what it will do.
@luabud what do you think the default should be?
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.
Love showNotification! As for the default value, my vote would be for "on-error" to avoid annoying those who feel strongly about notifications. But I don't have a strong opinion on this 😊
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.
@luabud, Initially I agreed that default "on-error" would make sense, but after some thoughts I'd vote for "on-warn". The reason is simple: if user is annoyed by notifications, it's clear what's happening and how to fix it. On contrary, it's unclear what's happening when extension doesn't do what it supposed to do and doesn't emit any warnings either.
|
I want to write tests to support the changes and have to ask, what's the reason to use |
Hamcrest provides better error messages when comparing objects that are complex. I also provides a way to include custom matchers and we can do fuzzy matching. This has been helpful in issues with Jedi Language Server. |
| """ | ||
| Compose error message from stderr, while trying to display most relevant data first. |
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.
| """ | |
| Compose error message from stderr, while trying to display most relevant data first. | |
| """Compose error message from stderr, while trying to display most relevant data first. |
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.
@Bobronium I don't we should rely on black to detect syntax errors. Jedi or Pylance can do a much better job at detecting these and adding an entry to the problems window that points to the exact line and column where the problem exists. This feels like it is adding additional responsibility to the black extension that I don't feel it should take on.
/cc @luabud what do you think?
| "on-warn", | ||
| "on-message" | ||
| ], | ||
| "scope": "resource", |
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.
| "scope": "resource", | |
| "scope": "machine", |
I don't think this should be resource, this setting need not have workspace folder level of granularity. It can be machine where it can be handled in both local and remote scenarios.
| "on-crash", | ||
| "on-error", | ||
| "on-warn", | ||
| "on-message" |
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 feel like these should be on-error, on-warn, always, and never. I also recommend adding enum descriptions.
An example, for enum descriptions:
"python.languageServer": {
"default": "Default",
"description": "Defines type of the language server.",
"enum": [
"Default",
"Jedi",
"Pylance",
"None"
],
"enumDescriptions": [
"Automatically select a language server: Pylance if installed and available, otherwise fallback to Jedi.",
"Use Jedi behind the Language Server Protocol (LSP) as a language server.",
"Use Pylance as a language server.",
"Disable language server capabilities."
],
"scope": "window",
"type": "string"
},
/cc @luabud Need your input on the enum values and the descriptions.
| "type": "array" | ||
| }, | ||
| "black-formatter.showNotification": { | ||
| "default": "on-warn", |
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.
| "default": "on-warn", | |
| "default": "on-error", |
I believe this should be on-error, and when we do show notification there should be a way to add a button to the displayed message to trigger a setting change. This might be a limitation of the LSP, but if we can run a command for VS Code we could make this work. That is probably a separate thing.
/cc @luabud this is a prime candidate for experiment.
|
@Bobronium If it is OK. I would like to update this PR with the latest extension template. We added few more configuration that make it easier to log to output and in cases where users want show notification. I will update the PR based on our intended plan, this way you will get credit for the idea when we merge it. |
|
@karthiknadig, sure! Thanks for a heads up. And thank you for picking this up. |
|
This is now incorporated into the black extension via the backing extension template. Added credits to this in the release notes. Closing this PR. The only part that was not used was the location extraction. Most syntax errors should be detected by language server like Pylance or Jedi. |
Closes #55
Addresses #38
Changes
show-formatting-messagessetting that toggles behaviour in#1Checks
Going to proceed with the last one one once I get overall feedback on changes