Closed
Description
Right now we use the ABC classes in pandas._typing to work around circular imports, but I think this has the effect of making our type checking practically non-existent. The ABCs are factory generated by an unannotated function, so they get replaced with Any
To illustrate, run mypy on a module with this content
from pandas.core.dtypes.generic import ABCDataFrame
some_obj = None # type: ABCDataFrame
reveal_type(some_obj)
Mypy runs without issue yielding
test.py:4: note: Revealed type is 'Any'
By contrast, using the actual DataFrame class:
import pandas as pd
some_obj = None # type: pd.DataFrame
reveal_type(some_obj)
Yields an error:
(pandas-dev) mypy test.py
test.py:3: error: Incompatible types in assignment (expression has type "None", variable has type "DataFrame")
test.py:4: note: Revealed type is 'pandas.core.frame.DataFrame'
I'm not sure the best approach here. Direct imports into pandas._typing should cause circular imports but the ABCs won't provide anything with type checking as long as they are factory generated.