astanin / python-tabulate

Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate.
https://pypi.org/project/tabulate/
MIT License
2.1k stars 163 forks source link

[bug] Program crashes when using maxcolwidths and a bool field #280

Open TheEvilMandarin opened 1 year ago

TheEvilMandarin commented 1 year ago

The maxcolwidths parameter does not work with an integer field. And with a bool field, the program breaks down with the error: AttributeError: 'bool' object has no attribute 'expandtabs' print(tabulate([["string", "integer"]] + [["some test string", "255454546"]], tablefmt="rounded_grid", maxcolwidths = [10, 2])) image

print(tabulate([["string", "bool"]] + [["some test string", "False"]], tablefmt="rounded_grid", maxcolwidths = [10, 2]))

/py_test/venv/lib/python3.8/site-packages/tabulate/__init__.py", line 1518, in _wrap_text_to_colwidths wrapped = wrapper.wrap(casted_cell) File "/usr/lib/python3.8/textwrap.py", line 351, in wrap chunks = self._split_chunks(text) File "/usr/lib/python3.8/textwrap.py", line 337, in _split_chunks text = self._munge_whitespace(text) File "/usr/lib/python3.8/textwrap.py", line 154, in _munge_whitespace text = text.expandtabs(self.tabsize) AttributeError: 'bool' object has no attribute 'expandtabs'