Skip to content
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

fix(python): Fix next on group by objects throw TypeError #19615

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

tylerriccio33
Copy link
Contributor

In #12868 , a direct call to the next method on a group by object raises an unintended AttributeError. In my pr, this raises a TypeError. For my fix, I caught the line throwing the error and re-raised it as a TypeError, since the line indicates the iter method has not been called yet. This fix feels a bit imperfect, and I'm not thrilled the try-except is performed every time the next method is called.

Pretty new to open source, so apologies if things are out of sorts. Thank you!

Copy link

codecov bot commented Nov 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.97%. Comparing base (0b0a914) to head (a62e7a2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19615   +/-   ##
=======================================
  Coverage   79.96%   79.97%           
=======================================
  Files        1536     1536           
  Lines      211374   211389   +15     
  Branches     2445     2445           
=======================================
+ Hits       169034   169052   +18     
+ Misses      41785    41782    -3     
  Partials      555      555           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -111,7 +111,13 @@ def __iter__(self) -> Self:
return self

def __next__(self) -> tuple[tuple[object, ...], DataFrame]:
if self._current_index >= len(self._group_indices):
try:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this try-except, we should return an object of a new class on __iter__. Then it is solved by the type system.

coastalwhite and others added 20 commits November 7, 2024 21:31
…offsetting by non-constant durations in the timezone-naive case (pola-rs#19616)
…e "$" character with reference to capture groups (vs use as a literal) (pola-rs#19529)
nameexhaustion and others added 22 commits November 7, 2024 21:31
…s#19620)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Stijn de Gooijer <[email protected]>
pola-rs#19687)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.