Closed
Description
Problem description
pd.io.formats.format._binify
defines line_width
as Union[np.int32, int]
:
pandas/pandas/io/formats/format.py
Line 1893 in 39602e7
however it is inconsistent with DataFrameFormatter.__init__
pandas/pandas/io/formats/format.py
Line 518 in 39602e7
and DataFrameFormatter._join_multiline
pandas/pandas/io/formats/format.py
Line 871 in 39602e7
which take and pass as-is Optional[int]
.
This leads to Mypy error:
pandas/io/formats/format.py:871: error: Argument 2 to "_binify" has incompatible type "Optional[int]"; expected "Union[int32, int]"
Providing default in _join_multiline
, i.e.
lwidth = self.line_width or DEFAULT_LINE_WIDTH
could be reasonable fix. One could also ignore the call:
col_bins = _binify(col_widths, lwidth) # type: ignore
but that leaves possible correctness problem.
Expected Output
Passing Mypy type check
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit : bee17d5f4c99e6d1e451cf9a7b6a1780aa25988d
python : 3.7.3.final.0
...
Additionally
mypy==0.730
CC @WillAyd