-
Notifications
You must be signed in to change notification settings - Fork 765
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
Explain types and how they work better #3892
Comments
Potential idea: |
Another idea: |
Most of pyright's errors do attempt to explain the cause of an error, but there are some (think "syntax error") where it should be self-explanatory. In other cases (e.g. "TypeVar appears only once in signature" or "expression is not used") where the diagnostic is indicative of some fundamental misunderstanding on the part of a user, but it's difficult to explain succinctly what the source of that confusion is or how they might remedy the error. Other investment ideas:
|
That's a pretty good explanation, but the recommended fix is likely wrong. (I say "likely wrong" beacuse it's difficult to say what the user actually intended in this case.) A better recommendation in this case is "change the annotation for parameter |
Well, this is why it needs to be trained only on your responses :) |
Another idea:
Here's an example: this._addDiagnostic(
this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues,
DiagnosticRule.reportGeneralTypeIssues,
Localizer.Diagnostic.annotationNotSupported(),
node.chainedTypeAnnotationComment
); That would instead put up a message like so:
That would jump to
|
@heejaechang had another idea, give each diagnostic a unique ID so that users can actually search for these errors. That would change the above to be something like:
|
Creating a unique ID and documentation for every diagnostic message would be a very significant undertaking and would come with significant maintenance cost. Last time I counted, there were over 600 diagnostic messages. For those reasons, I would vote against that approach. I think some of the other ideas above are much more feasible. |
Had a meeting with the typescript team. Here's a summary of what was discussed:
|
C# team had similar feedback:
|
Linked items:
See the discussion here:
microsoft/pyright#3953 (reply in thread)
And the numerable other cases where how types should be used was confusing.
A lot of the ones in this category might be avoided if we could explain things more clearly:
https://github.com/microsoft/pyright/issues?q=is%3Aissue+is%3Aclosed+label%3A%22as+designed%22
This issue is to provide a way to better explain python typing to Pylance users.
The text was updated successfully, but these errors were encountered: