-
Notifications
You must be signed in to change notification settings - Fork 141
Closed as duplicate of#544
Description
Summary
ty incorrectly thinks Pandas boolean indexing returns Series.
Reproducible example:
import pandas as pd
def filter_data(data: pd.DataFrame) -> pd.DataFrame:
return data[(data["a"] == 1)]
data = pd.DataFrame(
{
"a": [1, 2, 3, 4],
"b": [4, 3, 2, 1],
}
)
print(filter_data(data))> ty version
ty 0.0.1-alpha.14 (3ececb07e 2025-07-08)
> ty check pandas-demo.py
WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
error[invalid-return-type]: Return type does not match returned value
--> pandas-demo.py:4:40
|
4 | def filter_data(data: pd.DataFrame) -> pd.DataFrame:
| ------------ Expected `DataFrame` because of return type
5 | return data[data["a"] == 1]
| ^^^^^^^^^^^^^^^^^^^^ expected `DataFrame`, found `Series[Any]`
|
info: rule `invalid-return-type` is enabled by default
Found 1 diagnostic
Pandas version is 2.3.0
Version
No response
Metadata
Metadata
Assignees
Labels
No labels