Open
Description
To Reproduce
from collections.abc import Sequence
from pandas import read_csv
cols1: Sequence[str] = ["a"]
def cols2(x: set[float]) -> bool: return sum(x) < 1.0
read_csv("file.csv", usecols=cols1) # mypy: "No overload variant of "read_csv" matches argument types "str", "Sequence[str]"
read_csv("file.csv", usecols=cols2) # no error from mypy
Expected behavior:
No error for usecols=cols1
, but an error for usecols=cols2
Actual behavior:
cols1
is not accepted, even though Sequence[str]
is "list like" (at least I think so; the term is nowhere defined) and its elements are "strings that correspond to column names"
cols2
is accepted, even though it is not a callable that can be "evaluated against the column names, returning names where the callable function evaluates to True"
Please complete the following information:
- OS: Microsoft Windows
- OS Version 10.0.19045.4651
- python version 3.11.9
- version of type checker: mypy 1.11.0
- version of installed
pandas-stubs
: 2.2.2.240603
Metadata
Metadata
Assignees
Labels
No labels