-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #19136 +/- ##
==========================================
- Coverage 79.78% 79.51% -0.28%
==========================================
Files 1531 1527 -4
Lines 208427 209204 +777
Branches 2913 2415 -498
==========================================
+ Hits 166295 166345 +50
- Misses 41581 42311 +730
+ Partials 551 548 -3 ☔ View full report in Codecov by Sentry. |
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] |
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.
Whys does mypy complain here?
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.
❯ 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)
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.
Then I think we must pass a seelctor
as we don't allow expression inputs here.
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 could reproduce the issue as well with the following:
pl.selectors.all() + pl.col("x")
which is at runtime a _selector_proxy_
, mypy still thinks it's a Expr
, hence the assert
in 3947452
(#19136)
Closes #19023