-
-
Notifications
You must be signed in to change notification settings - Fork 146
Closed
Description
Describe the bug
The latest release of pandas-stubs seems to have added some typing that is overly restrictive. I'm seeing many instances of Invalid conditional operand of type "Unknown | Series[_bool]"
where before it did not appear.
To Reproduce
Running pandas 2.2.3 + pandas-stubs 2.2.3.250308 + pyright 1.1.396
df = pd.DataFrame(
data={"foo": "bar"},
index=["one"],
)
if pd.isna(df.loc["one"]["foo"]):
pass
assert df.loc["one"]["foo"] == "bar"
Pyright 1.1.396 returns these errors:
error: Invalid conditional operand of type "Series[bool]"
Method __bool__ for type "Series[bool]" returns type "NoReturn" rather than "bool" (reportGeneralTypeIssues)
error: Invalid conditional operand of type "Unknown | Series[_bool]"
Method __bool__ for type "Series[_bool]" returns type "NoReturn" rather than "bool" (reportGeneralTypeIssues)
The first error is for the pd.isna()
, the second is for the equality assertion. But in both cases, df.loc["one"]["foo"]
is a str
, so the type checking ought to work out.
Please complete the following information:
- OS: MacOS
- OS Version: Sequoia 15.3.1
- Python: 3.12
- Pyright: 1.1.396
- pandas-stubs: 2.2.3.250308
Additional context
Did not see this on pandas-stubs 2.2.3.241126.
Metadata
Metadata
Assignees
Labels
No labels