Skip to content

Honor disable_numparse while wrapping column widths - #471

Open
ShamikOfficial wants to merge 1 commit into
astanin:masterfrom
ShamikOfficial:fix-disable-numparse-wrapping-448
Open

ShamikOfficial wants to merge 1 commit into
astanin:masterfrom
ShamikOfficial:fix-disable-numparse-wrapping-448

Conversation

@ShamikOfficial

Copy link
Copy Markdown

Fixes #448

While wrapping cells, _type(cell, numparse) passed numparse into has_invisible. disable_numparse was therefore ignored, and a value such as 100,120 was parsed as a number.

The flag is now passed as numparse=numparse.

Tested with the new regression test and the existing disable_numparse tests.

The flag was bound to has_invisible, so disable_numparse was ignored for values like 100,120.

Co-authored-by: Cursor <cursoragent@cursor.com>
@killtheprompt

Copy link
Copy Markdown

The keyword argument fixes the disable_numparse=True case. There is still a default-options case from #448 at d3abd94:

from tabulate import tabulate

tabulate([["100,120"]], tablefmt="grid")  # succeeds
tabulate([["100,120"]], tablefmt="grid", maxcolwidths=20)
# ValueError: invalid literal for int() with base 10: '100,120'

Adding disable_numparse=True to the second call now succeeds. Local parametrized checks confirm that distinction; the existing suite also passes (383 passed, 1 skipped, Python 3.13).

Related: #449 already includes a fallback for the conversion failure and tests both settings. If this PR is intentionally limited to honoring disable_numparse, it may help to clarify that scope rather than mark all of #448 as fixed.

Prepared with Codex assistance; the checks above were executed locally against this PR's head.

@carlitogwapito

Copy link
Copy Markdown

Here's a small optional test-only commit, directly on your current head.

It uses disable_numparse=[0] with a real width-4 wrap: 100,120 becomes the text lines 100, and 120, while the neighboring 1.2300 still formats as 1.23.

Two guards worth keeping: exercise selective disabling rather than only the global flag, and check the numeric neighbor so a blanket-disable workaround can't pass unnoticed.

On Python 3.14.4, the test passes your pinned source; the base raises the integer-conversion error. The unchanged selective-parsing and wrapping controls pass on both. Configured Ruff checks pass. I haven't run full tox/doctests, pinned hooks, builds, CLI or the version/OS/wide-character matrix. This doesn't address the separate default-options caveat already noted above.

To run just the added file: python -m pytest test/test_selective_wrapped_numparse.py -q.

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.

problem in tabulate 0.10.0 on python 3.11.12 with cell values like "100,120"

3 participants