Skip to content

pyrefly report counts inherited typed stub methods as untyped in NumPy #3519

@jorenham

Description

@jorenham

For __init__.pyi, pyrefly report outputs

        {
          "kind": "function",
          "name": "numpy.ndarray.__array_wrap__",
          "n_typable": 4,
          "n_typed": 4,
          "n_any": 0,
          "n_untyped": 0,
          "location": {
            "line": 2138,
            "column": 5
          }
        },

So it correctly counts ndarray.__array_wrap__ as fully typed.

However, for core/defchararray.pyi, it outputs

        {
          "kind": "function",
          "name": "numpy._core.defchararray.chararray.__array_wrap__",
          "n_typable": 4,
          "n_typed": 0,
          "n_any": 0,
          "n_untyped": 4,
          "location": {
            "line": 582,
            "column": 5
          }
        },

The chararray here is a subclass of ndarray. Because the chararray.__array_wrap__ method has the same signature as ndarray.__array_wrap__, there is no need to override it in the stubs.
Yet pyrefly report counts chararray.__array_wrap__, which is statically the very same method as ndarray.__array_wrap__, as fully untyped.

I suspect that the issue is that pyrefly report looks at the .py, sees that there's a chararray.__array_wrap__ method. It then, without considering the superclass, "requires" that chararray.__array_wrap__ must also exists in the stubs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    quansightreportIssues related to `pyrefly report`

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions