-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bb3d48
commit 73cf244
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import asdict | ||
from dataclasses import dataclass | ||
from typing import Sequence | ||
|
||
import pandas as pd | ||
import polars as pl | ||
|
||
import narwhals.stable.v1 as nw | ||
|
||
|
||
def test_dataclass() -> None: | ||
# https://github.com/narwhals-dev/narwhals/issues/1486 | ||
@dataclass | ||
class Foo: | ||
a: Sequence[int] | ||
|
||
# dry-run to check that none of these error | ||
asdict(Foo(pd.Series([1, 2, 3]))) | ||
asdict(Foo(pl.Series([1, 2, 3]))) # type: ignore[arg-type] | ||
asdict(Foo(nw.from_native(pl.Series([1, 2, 3]), series_only=True))) # type: ignore[arg-type] | ||
asdict(Foo(nw.from_native(pd.Series([1, 2, 3]), series_only=True))) # type: ignore[arg-type] |