-
Notifications
You must be signed in to change notification settings - Fork 173
Open
Description
Numbers are cast to float
before format()
ing, which prevents custom formatting logic provided by subclasses. tabulate/__init__.py#L1350
Example
from tabulate import tabulate
from prefixed import Float
tabulate([[Float(1)]], floatfmt='h')
ValueError: Unknown format code 'h' for object of type 'float'
Background
Proposals to extend the built-in python formats have been rejected, because subclasses are intended to satisfy this use case.
This regression was introduced in version 0.2
. 5115cea/tabulate.py#L154
Related to #297.
Proposal
Only apply the float
cast in _format()
to strings.
Edit: And decimal
align any string by .
or \d([^d])
in _afterpoint()
.
Metadata
Metadata
Assignees
Labels
No labels