From e8a9e9f88d22a9c2fe5fcc87aaa12659d41a8761 Mon Sep 17 00:00:00 2001 From: ANSHUL SINGH Date: Fri, 16 Oct 2026 17:40:14 +0000 Subject: [PATCH] Honor disable_numparse when wrapping columns with maxcolwidths. _wrap_text_to_colwidths passed the per-cell numparse flag to _type positionally, so it filled has_invisible and numparse stayed True. Values such as '80,443' were then cast with int() and raised ValueError even when disable_numparse=True. Pass numparse by keyword. Fixes #428 --- tabulate/__init__.py | 2 +- test/test_regression.py | 11 +++++++++++ 2 files changed, 12 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_regression.py b/test/test_regression.py index 9555676..763f7a9 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -598,3 +598,14 @@ def test_github_escape_pipe_character(): result = tabulate([["foo|bar"]], headers=("spam|eggs",), tablefmt="github") expected = "| spam\\|eggs |\n|:------------|\n| foo\\|bar |" assert_equal(expected, result) + +def test_disable_numparse_with_maxcolwidths(): + "Regression: disable_numparse is honored when wrapping columns (issue #428)" + result = tabulate( + [["ports", "str", "comma-separated port list", "80,443"]], + ["name", "type", "desc", "default"], + tablefmt="grid", + disable_numparse=True, + maxcolwidths=40, + ) + assert "80,443" in result