Skip to content

Conversation

cmp0xff
Copy link
Contributor

@cmp0xff cmp0xff commented Sep 17, 2025

Thank you @hamdanal, the idea in #1362 really helps. Also grateful to @Dr-Irv for tagging me there.

@cmp0xff cmp0xff requested a review from Dr-Irv September 17, 2025 21:32
@cmp0xff cmp0xff changed the title fix(series): #1372 🪟✖️ cumprod fix(series): #1372 🧱✖️ cumprod Sep 18, 2025
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small naming issue in the test, otherwise good to go

@overload
def cumprod(
self,
self: SupportsGetItem[Scalar, _SupportsMul[S1]],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that work with classes that have overloads for __mul__? My understanding from microsoft/pyright#6549 (comment) is that type checkers will then pick the first overload. It might be okay in this case (and I wish we could use this pattern!) - just something to be aware of when using this patterns in more places.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that it would matter, because S1 are types we define in pandas as well as fundamental types (int, float, etc.), so I think we will be fine. It's a bit different than the case you wrote up, because of the use of _SupportsMul[S1] requiring the type that supports __mul__() to be in S1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I with this pattern can help us saving efforts, too.

  • Note that there are already SupportsAdd and SupportsMul in _typeshed. They are however different somehow from our _SupportsAdd and _SupportsMul. We probably need a renaming in the near future.
  • It would be great if we could work out a pattern that deal with typing changes like A.__operate__(B) ->B and A.__operate__(A) -> B, for example bool + int -> int, int / int -> float.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cmp0xff

@Dr-Irv Dr-Irv merged commit 8e5c754 into pandas-dev:main Sep 18, 2025
13 checks passed
@cmp0xff cmp0xff deleted the hotfix/cmp0xff/1372-cumprod branch September 18, 2025 18:17
@cmp0xff cmp0xff mentioned this pull request Sep 28, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Series#cumprod overloads
3 participants