Skip to content

Conversation

@pavelzw
Copy link
Contributor

@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
@codecov
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.51%. Comparing base (1f48036) to head (3947452).
Report is 1833 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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
Contributor 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.

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 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)

@pavelzw
Copy link
Contributor Author

pavelzw commented Jul 8, 2025

superseded by #23351

@pavelzw pavelzw closed this Jul 8, 2025
@pavelzw pavelzw deleted the invalid-selectors branch July 8, 2025 08:01
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