DataFrame.interpolate method return type does not honor default inplace argument · Issue #691 · pandas-dev/pandas-stubs (original) (raw)
Using pandas-stubs-2.0.1.230501.
inplace defaults to False, so the below shoudl return a new DataFrame. But pyright thinks the return type is DataFrame | None. Here is some code showing the problem:
import pandas as pd
df: pd.DataFrame = -pd.DataFrame()
df = df.interpolate(method="linear") # pyright reports the below message for this line
Expression of type "DataFrame | None" cannot be assigned to declared type "DataFrame"
Type "DataFrame | None" cannot be assigned to type "DataFrame"
Type "None" cannot be assigned to type "DataFrame"
But if I repalce the line with the below, then pyright is happy:
df = df.interpolate(method="linear", inplace=False)