From d3abd949c1cd0c5b83de981a0e86c5f62835d321 Mon Sep 17 00:00:00 2001 From: Shamik Basu Date: Sun, 11 Oct 2026 17:52:48 -0700 Subject: [PATCH 1/2] Pass numparse by keyword when wrapping table cells. The flag was bound to has_invisible, so disable_numparse was ignored for values like 100,120. Co-authored-by: Cursor --- tabulate/__init__.py | 2 +- test/test_output.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tabulate/__init__.py b/tabulate/__init__.py index 12a2950..c13366d 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -1652,7 +1652,7 @@ def _wrap_text_to_colwidths( else ( str(cell) if cell == "" or _isnumber(cell) - else str(_type(cell, numparse)(cell)) + else str(_type(cell, numparse=numparse)(cell)) ) ) wrapped = [ diff --git a/test/test_output.py b/test/test_output.py index ea3da87..41d99b8 100644 --- a/test/test_output.py +++ b/test/test_output.py @@ -3292,6 +3292,18 @@ def test_disable_numparse_true(): assert_equal(expected, result) +def test_disable_numparse_maxcolwidths_keeps_thousands_separator(): + "Wrapping must not parse a disabled numeric column such as 100,120" + result = tabulate( + [["100,120"]], + headers=["x"], + tablefmt="plain", + maxcolwidths=[20], + disable_numparse=True, + ) + assert "100,120" in result + + def test_disable_numparse_list(): "Output: Default table output, but with number parsing selectively disabled" table_headers = ["h1", "h2", "h3"] From 42f6421d0942dcf9fa2a837d034dac247cb23e76 Mon Sep 17 00:00:00 2001 From: Shamik Basu Date: Fri, 16 Oct 2026 21:45:35 -0700 Subject: [PATCH 2/2] test: cover selective numparse while wrapping cells Exercise disable_numparse=[0] with a real wrap so text commas stay literal while a numeric neighbor still formats. Co-authored-by: Cursor --- test/test_selective_wrapped_numparse.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/test_selective_wrapped_numparse.py diff --git a/test/test_selective_wrapped_numparse.py b/test/test_selective_wrapped_numparse.py new file mode 100644 index 0000000..4656dce --- /dev/null +++ b/test/test_selective_wrapped_numparse.py @@ -0,0 +1,17 @@ +from tabulate import tabulate + + +def test_selective_numparse_preserves_wrapped_text_and_numeric_neighbor(): + result = tabulate( + [["100,120", "1.2300"]], + headers=["id", "amount"], + tablefmt="plain", + maxcolwidths=[4, None], + disable_numparse=[0], + ) + + assert [line.split() for line in result.splitlines()] == [ + ["id", "amount"], + ["100,", "1.23"], + ["120"], + ]