You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "C:\Python38\lib\site-packages\tabulate\__init__.py", line 2061, in tabulate
list_of_lists = _wrap_text_to_colwidths(
File "C:\Python38\lib\site-packages\tabulate\__init__.py", line 1516, in _wrap_text_to_colwidths
str(cell) if _isnumber(cell) else _type(cell, numparse)(cell)
TypeError: NoneType takes no arguments
reason:
>>> type(None)(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: NoneType takes no arguments
solution:
str(cell) if _isnumber(cell) else _type(cell, numparse)(cell)
to str(cell or '') if _isnumber(cell) or cell is None else _type(cell, numparse)(cell)
The text was updated successfully, but these errors were encountered:
Seems very related: I get "list index out of range" when there are no elements to tabulate and maxcolwidths is set (e.g. tabulate([],maxcolwidths=[2])):
File ....venv/lib/python3.12/site-packages/tabulate/__init__.py:2054, in tabulate(tabular_data, headers, tablefmt, floatfmt, intfmt, numalign, stralign, missingval, showindex, disable_numparse, colalign, maxcolwidths, rowalign, maxheadercolwidths)
2051 list_of_lists, separating_lines = _remove_separating_lines(list_of_lists)
2053 if maxcolwidths is not None:
-> 2054 num_cols = len(list_of_lists[0])
2055 if isinstance(maxcolwidths, int): # Expand scalar for all columns
2056 maxcolwidths = _expand_iterable(maxcolwidths, num_cols, maxcolwidths)
Writing here since basically the same code area/workflow
https://github.com/astanin/python-tabulate/blob/95ae5eb61ef969749e904c90ab429003238d6212/tabulate/__init__.py#L1532C27-L1532C61
str(cell) if _isnumber(cell) else _type(cell, numparse)(cell)
to
str(cell or '') if _isnumber(cell) or cell is None else _type(cell, numparse)(cell)
The text was updated successfully, but these errors were encountered: