Closed otsuka closed 2 months ago
Thanks for the PR! Personally, I like this format and am inclined to merge it. However, your parsing algorithm is inadequate; what would happen when a quoted type itself contains "
?
a: int = 0
a = "'\"" # "Literal['\'"']" is incompatible with "int"
Considering that the quotes are a part of the localized messages, I wonder if Pyright's maintainers could be convinced to add Markdown (RFC 5646/BCP 47: x-markdown
) as a supported locale. The conversion would then be trivial with built-in converters like DocMarkdownToHtmlConverter
.
The parsing regexp I used wouldn't handle the case you mentioned. It's indeed challenging to address this issue, even if I were to avoid using regexp. I think that it's unlikely Pyright would add Markdown support, so achieving a perfect solution in the current state seems difficult.
After much consideration, I decided not to merge this, for the aforementioned reason, and that a full-fledged parsing algorithm would be too much of a maintenance burden. On the other hand, I too have taken a liking to this idea of pretty-formatting diagnostic messages. If I ever find a simple way to implement it, I will definitely make it a feature.
I’ve always found the output messages from Pyright to be somewhat hard to read due to the excessive use of quotation marks and indentation. To address this, I’ve modified this plugin to add an option that allows tooltips to be displayed in a format that I find slightly more readable. I’ve attached a screenshot comparing the output formats. I believe the improvement would be even more noticeable with longer messages and deeper indentation.
This is a feature that isn’t even available in VSCode + Pylance, and while I personally find it appealing, I understand that others may have different preferences.
I don’t expect this Pull Request to be merged as is, so feel free to close it. However, I would be delighted if a similar feature were implemented in the future.
normal
pretty format