`TypeIs` guard does not narrow mixed input union in Pyrefly
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start with the is_into_series type guard in narwhals/stable/v2/dependencies and the typing behavior described in the linked Pyrefly issue #4849. Check whether the guard can narrow the shown union in Pyrefly while following the relevant typing specification. Done means the example narrows value sufficiently for nw.from_native(value, series_only=True) to type-check, or the issue documents why Narwhals cannot provide that narrowing.
Written by the indexing model from the issue text.
Description
Not sure if narwhals can do something on the typing side, but I recently stumbled over this situation here:
from collections.abc import Iterable
from typing import Any, reveal_type
import narwhals.stable.v2 as nw
from narwhals.stable.v2.dependencies import is_into_series
def func(value: nw.IntoSeries | Iterable[Any] | None) -> None:
if is_into_series(value):
reveal_type(value)
nw.from_native(value, series_only=True)
for which pyrefly produces:
ERROR No matching overload found for function `narwhals.stable.v2.from_native` called with arguments: (Iterable[Any] | NativeSeries | None, series_only=Literal[True]) [no-matching-overload]
However, pyrefly seems to just follow the spec:
https://github.com/facebook/pyrefly/issues/4849
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 242
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 49
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from narwhals-dev/narwhals
-
Export `EagerAllowed` and `IntoBackend` from stable.v2Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
narwhals-dev/narwhals#4154 ·
Maintainers usually reply within 1 day
-
ci ibis
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
narwhals-dev/narwhals#3726 · 6 comments ·
Maintainers usually reply within 1 day
-
dask
Difficulty 4/5 3-5 days Newbie friendliness 48/100
narwhals-dev/narwhals#4153 ·
Maintainers usually reply within 1 day
-
`&`, `|` and `^` on integer columns are inconsistent across backendsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
narwhals-dev/narwhals#4150 ·
Maintainers usually reply within 1 day
-
`Series.scatter`: wrong results for duplicate, negative, out-of-bounds and null indices (pyarrow), and dtype issues (pandas)Possibly taken A pull request linked to this issue is open or already merged. Openbug: incorrect result
Difficulty 4/5 3-5 days Newbie friendliness 48/100
narwhals-dev/narwhals#4145 · 1 comment ·
Maintainers usually reply within 1 day
All issues in narwhals-dev/narwhals
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dbt-labs/spark-utils#51 ·
-
bug pydanty:is-working
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
pydantic/pydantic-ai#13444 ·
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
changelog investigate
Difficulty 1/5 Under an hour Newbie friendliness 68/100
ramnes/notion-sdk-py#502 ·