From 5427bd3208cf4b8c272482c9d4e42e48fb92a1d7 Mon Sep 17 00:00:00 2001 From: Luis Sanchez Date: Sat, 8 Feb 2025 18:17:53 -0500 Subject: [PATCH] Fix cast errors --- tabulate/__init__.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tabulate/__init__.py b/tabulate/__init__.py index b15d7f0..8b773ae 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -1641,17 +1641,12 @@ def _wrap_text_to_colwidths(list_of_lists, colwidths, numparses=True): if width is not None: wrapper = _CustomTextWrap(width=width) - # Cast based on our internal type handling. Any future custom - # formatting of types (such as datetimes) may need to be more - # explicit than just `str` of the object. Also doesn't work for - # custom floatfmt/intfmt, nor with any missing/blank cells. - casted_cell = ( - str(cell) if _isnumber(cell) else _type(cell, numparse)(cell) - ) + + casted_cell = str(cell) + wrapped = [ - "\n".join(wrapper.wrap(line)) + "\n".join(wrapper.wrap(line.strip())) for line in casted_cell.splitlines() - if line.strip() != "" ] new_row.append("\n".join(wrapped)) else: