Skip to content

Include classes in pyrefly report? #2110

@MarcoGorelli

Description

@MarcoGorelli

pyright --verifytypes includes classes in its report

For example, if I have

class Animal:
    def foo(self, a) -> None:
        ...

class Cat(Animal):
    ...

then pyright --verifytypes foo --outputjson tells me

{
    "version": "1.1.408",
    "time": "1768396883903",
    "generalDiagnostics": [],
    "summary": {
        "filesAnalyzed": 1,
        "errorCount": 0,
        "warningCount": 0,
        "informationCount": 0,
        "timeInSec": 0.713
    },
    "typeCompleteness": {
        "packageName": "foo",
        "packageRootDirectory": "/home/marcogorelli/tmp-repo/foo",
        "moduleName": "foo",
        "moduleRootDirectory": "/home/marcogorelli/tmp-repo/foo",
        "ignoreUnknownTypesFromImports": false,
        "pyTypedPath": "/home/marcogorelli/tmp-repo/foo/py.typed",
        "exportedSymbolCounts": {
            "withKnownType": 0,
            "withAmbiguousType": 0,
            "withUnknownType": 3
        },
        "otherSymbolCounts": {
            "withKnownType": 0,
            "withAmbiguousType": 0,
            "withUnknownType": 0
        },
        "missingFunctionDocStringCount": 1,
        "missingClassDocStringCount": 2,
        "missingDefaultParamCount": 0,
        "completenessScore": 0,
        "modules": [
            {
                "name": "foo"
            }
        ],
        "symbols": [
            {
                "category": "class",
                "name": "foo.Animal",
                "referenceCount": 2,
                "isExported": true,
                "isTypeKnown": false,
                "isTypeAmbiguous": false,
                "diagnostics": [
                    {
                        "file": "",
                        "severity": "warning",
                        "message": "No docstring found for class \"foo.Animal\""
                    }
                ]
            },
            {
                "category": "method",
                "name": "foo.Animal.foo",
                "referenceCount": 1,
                "isExported": true,
                "isTypeKnown": false,
                "isTypeAmbiguous": false,
                "diagnostics": [
                    {
                        "file": "/home/marcogorelli/tmp-repo/foo/__init__.py",
                        "severity": "warning",
                        "message": "No docstring found for function \"foo.Animal.foo\"",
                        "range": {
                            "start": {
                                "line": 1,
                                "character": 8
                            },
                            "end": {
                                "line": 1,
                                "character": 11
                            }
                        }
                    },
                    {
                        "file": "/home/marcogorelli/tmp-repo/foo/__init__.py",
                        "severity": "error",
                        "message": "Type annotation for parameter \"a\" is missing",
                        "range": {
                            "start": {
                                "line": 1,
                                "character": 8
                            },
                            "end": {
                                "line": 1,
                                "character": 11
                            }
                        }
                    }
                ]
            },
            {
                "category": "class",
                "name": "foo.Cat",
                "referenceCount": 1,
                "isExported": true,
                "isTypeKnown": false,
                "isTypeAmbiguous": false,
                "diagnostics": [
                    {
                        "file": "",
                        "severity": "warning",
                        "message": "No docstring found for class \"foo.Cat\""
                    },
                    {
                        "file": "",
                        "severity": "error",
                        "message": "Type of base class \"foo.Animal\" is partially unknown"
                    }
                ]
            }
        ]
    }
}

Note how it tells me that Cat is partially unknown because its base class Animal is partially unknown

Is there a way to get something similar from pyrefly?

{
  "/home/marcogorelli/tmp-repo/foo/__init__.py": {
    "line_count": 8,
    "functions": [
      {
        "name": "foo.Animal.foo",
        "return_annotation": "None",
        "parameters": [
          {
            "name": "self",
            "annotation": null,
            "location": {
              "start": {
                "line": 2,
                "column": 13
              },
              "end": {
                "line": 2,
                "column": 17
              }
            }
          },
          {
            "name": "a",
            "annotation": null,
            "location": {
              "start": {
                "line": 2,
                "column": 19
              },
              "end": {
                "line": 2,
                "column": 20
              }
            }
          }
        ],
        "location": {
          "start": {
            "line": 2,
            "column": 5
          },
          "end": {
            "line": 3,
            "column": 12
          }
        }
      }
    ],
    "suppressions": []
  }
}

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions