polars icon indicating copy to clipboard operation
polars copied to clipboard

fix(python): throw exception with '+' on selectors

Open coastalwhite opened this issue 1 year ago • 3 comments

Fixes #13986.

This PR adds an exception and hint when using the add operator between two selectors. It shows the following error:

unsupported operand type(s) for op: ('Selector' + 'Selector')

Hint: utilize the OR `|` operator for a selection union or the AND `&` operator for a selection intersection.

@stinodego can you take a look at this?

coastalwhite avatar Jun 21 '24 15:06 coastalwhite

I don't think this is a good idea. You can think of selectors as sets, and you cannot 'add' two sets.

We shouldn't panic of course, but rather throw a helpful error message.

I'll defer to the man himself though: @alexander-beedie

stinodego avatar Jun 21 '24 21:06 stinodego

Okay, did that now. Funnily enough, I originally wrote a patch that threw an exception but changed it for this. So it was just a matter of pressing Ctrl + Z a bunch of times.

coastalwhite avatar Jun 24 '24 07:06 coastalwhite

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 80.88%. Comparing base (8a6bf4b) to head (3e7307b). Report is 1423 commits behind head on main.

Files with missing lines Patch % Lines
py-polars/polars/selectors.py 40.00% 2 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17117      +/-   ##
==========================================
+ Coverage   80.86%   80.88%   +0.01%     
==========================================
  Files        1456     1456              
  Lines      191141   191338     +197     
  Branches     2728     2743      +15     
==========================================
+ Hits       154562   154756     +194     
+ Misses      36073    36072       -1     
- Partials      506      510       +4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 24 '24 07:06 codecov[bot]