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): Revert type hint change on expression inputs #12792

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ def gather(
):
indices_lit = F.lit(pl.Series("", indices, dtype=UInt32))._pyexpr
else:
indices_lit = parse_as_expression(indices)
indices_lit = parse_as_expression(indices) # type: ignore[arg-type]
return self._from_pyexpr(self._pyexpr.gather(indices_lit))

def get(self, index: int | Expr) -> Self:
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
NumericLiteral, TemporalLiteral, str, bool, bytes, List[Any]
]
# Inputs that can convert into a `col` expression
IntoExprColumn: TypeAlias = Union["Expr", "Series", str, "np.ndarray"]
IntoExprColumn: TypeAlias = Union["Expr", "Series", str]
# Inputs that can convert into an expression
IntoExpr: TypeAlias = Union[PythonLiteral, IntoExprColumn, None]

Expand Down
5 changes: 4 additions & 1 deletion py-polars/tests/unit/interop/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def test_view_deprecated() -> None:

def test_numpy_disambiguation() -> None:
a = np.array([1, 2])
assert pl.DataFrame({"a": a}).with_columns(b=a).to_dict(as_series=False) == {
df = pl.DataFrame({"a": a})
result = df.with_columns(b=a).to_dict(as_series=False) # type: ignore[arg-type]
expected = {
"a": [1, 2],
"b": [1, 2],
}
assert result == expected