Does Pandas (natively) support mypy type hints?

Viewed 1088

does pandas have support for mypy type hints? I want to type function that can recieve and return pandas Dataframe and Series. I have tried

from pandas.core.frame import DataFrame


def f() -> DataFrame:
    return {}

but I get

error: Skipping analyzing 'pandas': found module but no type hints or library stubs

If I silence this error by adding type: ignore, then the mypy runs without error, despite the function not returning a dataframe. I have also tried:

import pandas as pd


def f() -> pd.DataFrame:
    return {}

Same result, both with and without the type: ignore comment. I have tried this against pandas1.0.4, 1.0.5, current master on git ( @3e8f14f711642418c57a9e991f75ea86878020a3 ) and with both mypy 0.770 and 0.782.

Does pandas not support mypy type hints? Is there any way I can do this? Thank you in advance for your help.

Note: I would like to do this with-in pandas+mypy only, external stubs exists like https://pypi.org/project/data-science-types/ but I would rather not depend on it

0 Answers
Related