microsoft / pyright

Static Type Checker for Python
Other
13.13k stars 1.4k forks source link

1.1.340: schema for --outputjson is not according to spec #6740

Closed Josverl closed 8 months ago

Josverl commented 9 months ago

Finding When running pyright 1.1.340 the schema for json outputs appears to have changed Specifically the generalDiagnostics file: string attribute appears to be missing and replaced by a uri attribute with a different schema.

the problem does not appear for 1.1.339 npx pyright@1.1.339 --project /workspaces/micropython-stubs/tests/quality_tests/feat_stdlib --outputjson Returns the expected schema.

Code or Screenshots

npx pyright --project /workspaces/micropython-stubs/tests/quality_tests/feat_stdlib --outputjson

{
    "version": "1.1.340",
    "time": "1702587966554",
    "generalDiagnostics": [
        {
            "uri": {
                "_key": "/workspaces/micropython-stubs/tests/quality_tests/feat_stdlib/check_os/check_uname.py",
                "_filePath": "/workspaces/micropython-stubs/tests/quality_tests/feat_stdlib/check_os/check_uname.py",
                "_query": "",
                "_fragment": "",
                "_isCaseSensitive": true,
                "_formattedString": "file:///workspaces/micropython-stubs/tests/quality_tests/feat_stdlib/check_os/check_uname.py"
            },
            "severity": "information",
            "message": "Type of \"os_uname\" is \"uname_result\"",
            "range": {
                "start": {
                    "line": 23,
                    "character": 12
                },
                "end": {
                    "line": 23,
                    "character": 20
                }
            }
        }
    ],
    "summary": {
        "filesAnalyzed": 17,
        "errorCount": 0,
        "warningCount": 0,
        "informationCount": 1,
        "timeInSec": 1.347
    }
}

VS Code extension or command-line

rchiodo commented 9 months ago

Thanks for the issue. This was caused by the change to add URI support. Fix should be in the next release.

erictraut commented 9 months ago

This is addressed in pyright 1.1.341, which I just published.

rnovacek commented 8 months ago

Looks like this is back with pyright 1.1.346.

npm exec --yes -- pyright@1.1.346 --outputjson:

{
    "version": "1.1.346",
    "time": "1705328887095",
    "generalDiagnostics": [
        {
            "uri": {
                "_key": "/home/radek/weareeight/Bundle-Builder/core/views.py",
                "_filePath": "/home/radek/weareeight/Bundle-Builder/core/views.py",
                "_query": "",
                "_fragment": "",
                "_isCaseSensitive": true,
                "_formattedString": "file:///home/radek/weareeight/Bundle-Builder/core/views.py"
            },
            "severity": "error",
            "message": "Cannot access member \"xyz\" for type \"HttpRequest\"\n  Member \"xyz\" is unknown",
            "range": {
                "start": {
                    "line": 299,
                    "character": 16
                },
                "end": {
                    "line": 299,
                    "character": 19
                }
            },
            "rule": "reportGeneralTypeIssues"
        }
    ],
    "summary": {
        "filesAnalyzed": 580,
        "errorCount": 1,
        "warningCount": 0,
        "informationCount": 0,
        "timeInSec": 12.999
    }
}

npm exec --yes -- pyright@1.1.345 --outputjson:

{
    "version": "1.1.345",
    "time": "1705328981656",
    "generalDiagnostics": [
        {
            "file": "/home/radek/weareeight/Bundle-Builder/core/views.py",
            "severity": "error",
            "message": "Cannot access member \"xyz\" for type \"HttpRequest\"\n  Member \"xyz\" is unknown",
            "range": {
                "start": {
                    "line": 299,
                    "character": 16
                },
                "end": {
                    "line": 299,
                    "character": 19
                }
            },
            "rule": "reportGeneralTypeIssues"
        }
    ],
    "summary": {
        "filesAnalyzed": 580,
        "errorCount": 1,
        "warningCount": 0,
        "informationCount": 0,
        "timeInSec": 13.729
    }
}

1.1.346 has uri but doesn't have file.

erictraut commented 8 months ago

@rchiodo, looks like one of your recent changes introduced another regression here. Could you please prioritize a fix for this? Also, let's look for a way to add a unit test to prevent future regressions like this.

erictraut commented 8 months ago

@rchiodo, actually, I've implemented a fix, and I'm going to do a hot-fix release since this regression will have a big impact on many pyright users.

erictraut commented 8 months ago

This is fixed in a hot-fix release of pyright 1.1.347, which I just published. @rnovacek, thanks for reporting the problem (again), and apologies for the regression.

rnovacek commented 8 months ago

Works as expected, thank you @erictraut

npm exec --yes -- pyright@1.1.347 --outputjson:

{
    "version": "1.1.347",
    "time": "1705348060881",
    "generalDiagnostics": [
        {
            "file": "/home/radek/weareeight/Bundle-Builder/core/views.py",
            "severity": "error",
            "message": "Cannot access member \"xyz\" for type \"HttpRequest\"\n  Member \"xyz\" is unknown",
            "range": {
                "start": {
                    "line": 299,
                    "character": 16
                },
                "end": {
                    "line": 299,
                    "character": 19
                }
            },
            "rule": "reportGeneralTypeIssues"
        }
    ],
    "summary": {
        "filesAnalyzed": 580,
        "errorCount": 1,
        "warningCount": 0,
        "informationCount": 0,
        "timeInSec": 12.369
    }
}