Skip to content

Fix per-column missing values when wrapping table text - #485

Draft
AlexXuz wants to merge 2 commits into
astanin:masterfrom
AlexXuz:fix/per-column-missingval-wrapping-20261027
Draft

AlexXuz wants to merge 2 commits into
astanin:masterfrom
AlexXuz:fix/per-column-missingval-wrapping-20261027

Conversation

@AlexXuz

@AlexXuz AlexXuz commented Oct 27, 2026

Copy link
Copy Markdown

Problem

Per-column missingval values work during formatting, but combining them with maxcolwidths and a None cell passes the entire sequence to the text wrapper. For example:

from tabulate import tabulate

print(tabulate(
    [[None, None], ["Alice", None]],
    missingval=["?", "N/A"],
    maxcolwidths=[10, 10],
    tablefmt="plain",
))

This raises AttributeError: 'list' object has no attribute 'splitlines' instead of rendering each column's marker.

Change

Use the corresponding missing-value marker for each column while wrapping, padding short sequences with the existing default empty string. Materialize non-string iterables once in tabulate() so iterators remain available for cell wrapping, header wrapping, and final formatting.

Regression tests cover lists, tuples, iterators, short and empty sequences, wrapped markers, unbounded columns, header-only wrapping, combined header/cell wrapping, and non-missing cells.

Validation

Tested with Python 3.12.14 and pytest 9.1.1:

  • New regression cases: 16 failed and 6 passed before the fix; all 22 pass afterward.
  • Full suite, including module and README doctests: 345 passed, 60 skipped.
  • git diff --check passes.

NumPy, pandas, and wcwidth were unavailable, so their optional tests were skipped. Ruff/tox and other Python versions were not run locally. Remote CI has not yet been verified.

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.

1 participant