Skip to content

Allow callable float formatters with normal numeric alignment - #513

Open
Aschenbath wants to merge 1 commit into
astanin:masterfrom
Aschenbath:fix/big20-20261123-bde6-tabulate-callable-format
Open

Aschenbath wants to merge 1 commit into
astanin:masterfrom
Aschenbath:fix/big20-20261123-bde6-tabulate-callable-format

Conversation

@Aschenbath

Copy link
Copy Markdown

floatfmt accepts a callable globally or alongside format strings in the per-column sequence. Callables receive parsed floats or the original Decimal, return text without another numeric conversion, and retain numeric alignment. Missing cells bypass the callable; callback exceptions propagate. Width detection accounts for ANSI codes and line breaks introduced by the callback.

Closes #297.

Added documentation and 26 regression cases; all fail on the unchanged baseline. Full tests and doctests pass on Python 3.12 and 3.10 (408 passed, 1 existing skip each), and Ruff lint/format pass. The ANSI-bytes path also uses a bytes replacement when stripping escape codes so those numeric inputs can reach the formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idea/Feature Request: Allow callable for floatfmt.

1 participant