-
-
Notifications
You must be signed in to change notification settings - Fork 155
GH1139 Series.rename inplace #1140
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
Conversation
|
@loicdiridollou let me know when you think you'll get to this. I'd like to do a new release soon, and want to know if I should wait for this change or not. |
|
I was planning to take care of it in the evening but if you need to make a
release feel free to go ahead !3;943 that.
…On Tue, Mar 4, 2025 at 2:58 PM Irv Lustig ***@***.***> wrote:
@loicdiridollou <https://github.com/loicdiridollou> let me know when you
think you'll get to this. I'd like to do a new release soon, and want to
know if I should wait for this change or not.
—
Reply to this email directly, view it on GitHub
<#1140 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMQNSQCSSP6NGEOAKRHH2T32SYAXNAVCNFSM6AAAAABYFNRBHCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJYG43DKMZVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: Dr-Irv]*Dr-Irv* left a comment (pandas-dev/pandas-stubs#1140)
<#1140 (comment)>
@loicdiridollou <https://github.com/loicdiridollou> let me know when you
think you'll get to this. I'd like to do a new release soon, and want to
know if I should wait for this change or not.
—
Reply to this email directly, view it on GitHub
<#1140 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMQNSQCSSP6NGEOAKRHH2T32SYAXNAVCNFSM6AAAAABYFNRBHCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJYG43DKMZVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
73a1f14 to
2a112e6
Compare
2a112e6 to
470ccf4
Compare
Dr-Irv
left a comment
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.
Pretty close. Will still wait to get this done before I release.
tests/test_series.py
Outdated
| # TODO this should not raise an error, the lambda is matched with Hashable | ||
| # check( | ||
| # assert_type(pd.Series([1, 2, 3]).rename(lambda x: x**2, inplace=True), None), type(None) | ||
| # ) |
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.
I think the solution here is to not use Renamer, and have the first overload be for Callable[[Any], Label] with Literal[True] returning None, then have the second overload be for Hashable | None returning Self and the third overload just having Mapping[Any, Label] as the argument.
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.
If I do so mypy seems to match the return of the expression with Any instead of None, let me see how I can address
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.
I have pushed for you to take a look but not sure how to address, this is a mypy issue and not pyright, pyright is happy with the current setup and does not flag it.
Dr-Irv
left a comment
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.
I got it to work. The issue is that Callable and Hashable are overlapping and mypy is having trouble with that. So instead of using Hashable, I used Scalar | tuple[Hashable, ...] which corresponds to the docs anyway.
So my review contains all the changes (as suggestions) that you should need to make.
pandas-stubs/core/series.pyi
Outdated
| @overload | ||
| def rename( # type: ignore[overload-overlap] | ||
| self, | ||
| index: Hashable | None, |
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.
| index: Hashable | None, | |
| index: Scalar | tuple[Hashable,...] | None, |
Dr-Irv
left a comment
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.
thanks @loicdiridollou
assert_type()to assert the type of any return valueAdded some test framework migration as this was how I originally found the issue with
rename