Closed
Description
Describe the bug
Display.float_format
is annotated as str | None
. However, the correct type should be Callable[[float], str]
. From the documentation:
display.float_format : callable
The callable should accept a floating point number and return
a string with the desired format of the number. This is used
in some places like SeriesFormatter.
See formats.format.EngFormatter for an example.
[default: None] [currently: None]
To Reproduce
MRE:
import pandas as pd
pd.options.display.float_format = '{:,.2f}'.format
df = pd.DataFrame([1.1, 2.2, 3.3, 4.4],
index=['a', 'b', 'c', 'd'],
columns=['value'])
print(df)
Mypy output:
$ mypy mre.py
foo.py:3: error: Incompatible types in assignment (expression has type "Callable[[VarArg(object), KwArg(object)], str]", variable has type "Optional[str]") [assignment]
Found 1 error in 1 file (checked 1 source file)
Please complete the following information:
- OS: Arch Linux
- OS Version: Linux 5.15.72
- Python 3.10.7
- Mypy and Pyright
pandas-stubs
version 1.5.3.230214
Metadata
Metadata
Assignees
Labels
No labels