Closed Josverl closed 2 years ago
Not all diagnostics have an associated diagnostic rule. For example, parse errors are emitted unconditionally and have no associated rule. Diagnostic rules are used only for diagnostics that can be disabled or enabled.
If a rule is associated with the diagnostic, it is included in the output. If it's not, the rule
field is omitted from the JSON output. This is how it is designed to work. If you are consuming this output, your code should be prepared to handle the case where there is no rule
.
Please refer to this documentation that documents the JSON schema. Note that rule
has a question mark after it, indicating that it's not guaranteed to be included in the output.
Understood,
Still; may I suggest adding a few lines of documentation to explain this, as just a ?
in a json example does not convey that much information.
Describe the bug Inconsistent JSON formatting for different types of errors makes it hard(er) to use the json output of pyright. specifically errors of type
"message": "Non-default argument follows default argument",
do not specify arule
node .To Reproduce Steps to reproduce the behavior.
--outputjson
on a set of files ( .py and .pyi , in which there are different types of issues.Expected behavior Expect the JSON report to have consistent schema and specify a rule of each reported error/warning. Expected 5 properties for each node in
generalDiagnostics
:Actual Some of the reported errors do not include a rule. ( see below last reported error )
Screenshots or Code
Inspected code files and configuration are located in this GIST
VS Code extension or command-line pyright is run from the commandline.
Additional context
pyright is installed using python pip : https://pypi.org/project/pyright/
also note that in this case also the number of files inspected (filesAnalyzed) appears to be incorrect, as only 2 files were inspected