Skip to content

Fix KeyError when colalign contains None for asciidoc tables - #520

Open
semiflux wants to merge 1 commit into
astanin:masterfrom
semiflux:fix/asciidoc-colalign-none
Open

semiflux wants to merge 1 commit into
astanin:masterfrom
semiflux:fix/asciidoc-colalign-none

Conversation

@semiflux

Copy link
Copy Markdown

colalign accepts None for a column to disable alignment, but the asciidoc formatter indexes its alignment map directly and raises KeyError: None. Fall back to left alignment, as the latex formatter already does for unmapped values.

Reproduction:

tabulate(
    [["spam", 41.9999], ["eggs", 451]],
    headers=["strings", "numbers"],
    tablefmt="asciidoc",
    colalign=(None, "right"),
)

Before: KeyError: None. After:

[cols="<11,>11",options="header"]
|====
| strings |   numbers
| spam |   41.9999
| eggs |       451
|====

Added a regression test; the full suite passes (383 passed, 1 skipped).

`colalign` entries set to `None` disable alignment for that column, but the asciidoc formatter looked the value up directly in its alignment map and raised KeyError. Fall back to left alignment, as the other formatters already do for missing alignment values.
@semiflux
semiflux force-pushed the fix/asciidoc-colalign-none branch from 52caa01 to 8958b22 Compare November 29, 2026 10:30
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