Skip to content

Commit 051cac7

Browse files
authored
Warning when colalign or headersalign is a str
1 parent 39813e2 commit 051cac7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tabulate/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,9 @@ def tabulate(
22082208
# then specific alignements
22092209
if colalign is not None:
22102210
assert isinstance(colalign, Iterable)
2211+
if isinstance(colalign, str):
2212+
print(
2213+
f"Warning in `tabulate`: As a string, `colalign` is interpreted as {[c for c in colalign]}. Did you mean `colglobalalign = \"{colalign}\"` or `colalign = (\"{colalign}\",)`?")
22112214
for idx, align in enumerate(colalign):
22122215
if not idx < len(aligns):
22132216
break
@@ -2233,6 +2236,9 @@ def tabulate(
22332236
# then specific header alignements
22342237
if headersalign is not None:
22352238
assert isinstance(headersalign, Iterable)
2239+
if isinstance(headersalign, str):
2240+
print(
2241+
f"Warning in `tabulate`: As a string, `headersalign` is interpreted as {[c for c in headersalign]}. Did you mean `headersglobalalign = \"{headersalign}\"` or `headersalign = (\"{headersalign}\",)`?")
22362242
for idx, align in enumerate(headersalign):
22372243
hidx = headers_pad + idx
22382244
if not hidx < len(aligns_headers):

0 commit comments

Comments
 (0)