Skip to content

Commit

Permalink
docs: fix typing example
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Dec 21, 2024
1 parent af6a1f2 commit ab7505f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/api-reference/typing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ from narwhals.typing import IntoDataFrameT, DataFrameT
df = pl.DataFrame({"a": [1, 2, 3]})


def func(df: IntoDataFrameT) -> IntoDataFrameT:
df = nw.from_native(df, eager_only=True)
return nw.to_native(df.select(b=nw.col("a")))
def func(df_native: IntoDataFrameT) -> IntoDataFrameT:
df = nw.from_native(df_native, eager_only=True)
return df.select(b=nw.col("a")).to_native()


reveal_type(func(df))
Expand All @@ -51,9 +51,9 @@ reveal_type(func_2(df))

Running `mypy` on it gives:
```console
$ mypy f.py
f.py:11: note: Revealed type is "polars.dataframe.frame.DataFrame"
f.py:17: note: Revealed type is "Any"
$ mypy t.py
t.py:13: note: Revealed type is "polars.dataframe.frame.DataFrame"
t.py:21: note: Revealed type is "Any"
Success: no issues found in 1 source file
```

Expand Down

0 comments on commit ab7505f

Please sign in to comment.