Skip to content

TYP: NDFrame.align is wrong #51863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbrockmendel opened this issue Mar 9, 2023 · 2 comments · Fixed by #51867
Closed

TYP: NDFrame.align is wrong #51863

jbrockmendel opened this issue Mar 9, 2023 · 2 comments · Fixed by #51867
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Mar 9, 2023

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]

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 9, 2023
@twoertwein
Copy link
Member

When does align return a non-tuple? Both _align_frame and _align_series always return a tuple, so I don't see how align can return anything but a tuple.

@jbrockmendel
Copy link
Member Author

It always returns a tuple. the annotation is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants