Repository navigation
Conversation
…n#494) When tabular data contains rows of varying lengths (ragged rows) and the first row has fewer columns than subsequent rows, _normalize_tabular_data previously computed headers_pad using only len(rows[0]). When headers was shorter than the maximum row length, the headers list remained shorter than the total number of columns, causing zip(cols, aligns, minwidths) to truncate the table columns. Now headers_pad uses the maximum column count across all non-separating data rows, ensuring all table columns are properly preserved and aligned. Fixes astanin#494
Rajpal14
force-pushed
the
fix/ragged-table-headers
branch
from
November 9, 2026 20:45
82d4bd1 to
8ee2ce1
Compare
Author
|
Hi maintainers, when you have time, could you please review this fix for #494? It includes a regression test for ragged rows with shorter headers, and the full test suite passes locally. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #494.
When tabular data contains rows of varying lengths (ragged rows) and the first row has fewer columns than subsequent rows,
_normalize_tabular_datacomputedheaders_padusing onlylen(rows[0]):If
headerswas shorter than the maximum column count across all data rows (e.g.tabulate([["a"], ["b", "KEEP"]], headers=["tail"])),headersremained shorter than the total number of columns. Later,zip(cols, aligns_copy, minwidths)truncated the columns to the length ofminwidths(derived fromheaders), silently dropping data columns like"KEEP".Solution
_normalize_tabular_datato computeheaders_padusing the maximum column count across all non-separating data rows (max(len(r) for r in rows if not _is_separating_line(r))).test_ragged_rows_with_short_headersintest/test_regression.pyto verify that columns beyond the first row's width are preserved when short headers are supplied.Verification
pytest test/): 307 passed, 60 skipped, 0 failed.