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: Invalid selectors not being recognized #19136

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

Conversation

pavelzw
Copy link

@pavelzw pavelzw commented Oct 8, 2024

Closes #19023

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Oct 8, 2024
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.76%. Comparing base (1f48036) to head (027f115).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #19136      +/-   ##
==========================================
- Coverage   79.78%   79.76%   -0.03%     
==========================================
  Files        1531     1531              
  Lines      208427   208446      +19     
  Branches     2913     2913              
==========================================
- Hits       166295   166262      -33     
- Misses      41581    41633      +52     
  Partials      551      551              

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

@pavelzw pavelzw marked this pull request as ready for review October 8, 2024 10:42
def test_invalid_selector() -> None:
df = pl.DataFrame(data={"x": [1, 2], "z": ["a", "b"]})
with pytest.raises(InvalidOperationError, match="invalid selector expression"):
df.drop(pl.col("x", "z") + 2) # type: ignore[arg-type]
Copy link
Member

Choose a reason for hiding this comment

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

Whys does mypy complain here?

Copy link
Author

Choose a reason for hiding this comment

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

❯ mypy py-polars/tests/unit/test_selectors.py
py-polars/tests/unit/test_selectors.py:822: error: Argument 1 to "drop" of "DataFrame" has incompatible type "Expr"; expected "str | _selector_proxy_ | Iterable[str | _selector_proxy_]"  [arg-type]
py-polars/tests/unit/test_selectors.py:824: error: Argument 1 to "drop" of "DataFrame" has incompatible type "Expr"; expected "str | _selector_proxy_ | Iterable[str | _selector_proxy_]"  [arg-type]
Found 2 errors in 1 file (checked 1 source file)

Copy link
Member

Choose a reason for hiding this comment

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

Then I think we must pass a seelctor as we don't allow expression inputs here.

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 rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No exception raised when doing Selector + list in DataFrame.drop.
2 participants