Skip to content

TYP: NDFrame.align is wrong #51863

Closed
@jbrockmendel

Description

@jbrockmendel

NDFrame.align is annotated as def align(self: NDFrameT, other: NDFrameT, ...) -> NDFrameT: but actually other does not need to match self and it usually returns a tuple[Self, type(other)]. The "usually" is because when broadcast_axis==1 and self.ndim != other.ndim it returns tuple[DataFrame, DataFrame] (xref #51856 id like to deprecate this special case).

I tried annotating this correctly and got 40ish complaints e.g pandas/core/generic.py:8994: error: Cannot determine type of "index" [has-type]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions