Skip to content

Accept tuples for rowalign and other sequence kwargs - #472

Open
ekanshul wants to merge 1 commit into
astanin:masterfrom
ekanshul:fix-434-rowalign-tuple
Open

ekanshul wants to merge 1 commit into
astanin:masterfrom
ekanshul:fix-434-rowalign-tuple

Conversation

@ekanshul

Copy link
Copy Markdown

Fixes #434.

tabulate(..., rowalign=("top", "bottom")) raised TypeError: can only concatenate tuple (not "list") to tuple. The same happened for maxheadercolwidths and any other sequence passed through _expand_iterable.

That helper padded with original + [default] * n. Lists work; tuples do not, even when no padding is needed (tuple + []). Other sequence kwargs (headers, colalign, …) already accept tuples.

Coerce original to a list before padding. Adds a unit test for _expand_iterable and a regression test that rowalign=tuple matches rowalign=list.

_expand_iterable concatenated the original sequence with a list of
padding values. That works for lists but raises TypeError for tuples
(`tuple + list`), even when no padding is needed. Coerce to a list
first so rowalign, maxheadercolwidths, and the other sequence kwargs
accept tuples like headers and colalign already do.

Fixes astanin#434
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.

tabulate() raises TypeError when rowalign is passed as a tuple instead of a list

1 participant