Skip to content

Apply integer formats to signed ANSI-colored values - #486

Open
rupayon123 wants to merge 1 commit into
astanin:masterfrom
rupayon123:fix/ansi-signed-integer-format-20261027
Open

rupayon123 wants to merge 1 commit into
astanin:masterfrom
rupayon123:fix/ansi-signed-integer-format-20261027

Conversation

@rupayon123

Copy link
Copy Markdown

A signed integer inside an ANSI color sequence is recognized as numeric but skips the requested integer format. For example, red -1234 with intfmt="," is printed as -1234, while the same unsigned value receives the separator.

Allow one optional sign in the existing color reconstruction and apply the requested format to signed values. When a format is omitted, retain the supplied text, including a leading plus, leading zeros or negative zero. Tests also cover a column without a corresponding per-column format.

On macOS arm64/Python 3.13.14, all 392 tests and doctests pass with one existing skip, including the NumPy, pandas and wcwidth tests. The pinned Ruff 0.15.4 checks, package builds and twine checks pass. Four CLI cases run from the built wheel produce the expected bytes. Optional Ruff 0.17.3 reports the same 269 existing diagnostics on pristine master and this patch; it introduces none. Other Python/OS combinations and visual terminal rendering were not tested locally.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the signed-number path at 843eaee. The optional sign is now included in the color reconstruction before integer formatting, while the no-format branch retains a leading plus, zeros, and negative zero as supplied. All eleven targeted color and intfmt cases pass locally on Python 3.14.8, including the per-column format control. I did not run the full dependency and platform matrix.

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.

2 participants