-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
BUG: Concat typing #36409
BUG: Concat typing #36409
Conversation
mypy fails in the CI check here because concat is called within NDFrame, which is not included in FrameOrSeriesUnion. I think part of the issue might be some odd behavior I'm seeing with Mapping and mypy. Still working through it, marking as a draft. |
@rhshadrach #30852 (review) might help with the backstory for this. It is worth noting that |
Thanks @simonjayhawkins, I've updated the type-hints to use NDFrame. We don't want FrameOrSeriesUnion here because concat can be called from NDFrame and we don't want FrameOrSeries because the argument could be a list of both frames and series. One other thing I'll note is that while trying to provide various overloads, I ran into this bug that seems to impact many uses of overload where the arguments are Mapping or Dict (among other things). |
Unrelated to this PR but what is the point of FrameOrSeriesUnion vs just using NDFrame? Just more user-friendly from an API perspective right? |
@WillAyd the naming was decided in #30582. Looking back through the PR I think both of us prefered a and I think somewhere in the history before that it was prefered to not have NDFrame in type annotations that might be visible to end users. I'm +1 on NDFrame and NDFrameT where more appropriate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
didn't we decide that NDFrame is confusing? so am confused by
@WillAyd you are now +1 on this? |
Within the scope of this PR I think it make sense to not try and use the Union type of two objects in the parent. Probably fine to have that Union from an API perspective but doesn't need to be forced internally |
ok then, should clarify in _typing on what should be used when for these types. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
cc @simonjayhawkins
Attempting to add typing to results in aggregation.transform. Here, the obj can be a Series but the list passed into concat contain frames. mypy correctly identifies this as an issue, I think concat needs to be typed as FrameOrSeriesUnion for this purpose.
When I try just typing the function definition and not the overload, mypy complains:
so I've changed the type of the overload to FrameOrSeriesUnion as well. I don't believe this is any weaker than the current state because it is an overload.