Skip to content

type error when using maxcolwidths with colored strings #359

@Camyll

Description

@Camyll

Issue: colored string type throwing an error in casted_cell assignment because _type method not equipped to handle it.
Can we either:

  • add a type check to see if cell is already a str before putting it through 'casted_cell'? This could avoid the need for edge case checks but I may be misunderstanding why this method was necessary to begin with.
  • add colored string type to _type method. From the method details it seems that it should be equipped to handle input '\x1b[43m\x1b[30m3\x1b[0m' but it throws an error
input value for 'cell': "3" (colored string)
Error: 
  File "/data/sandcastle/boxes/fbsource/buck-out/v2/gen/fbcode/e104f4d0e1969b09/pytorchrelengoncall/__syncdiag__/syncdiag#link-tree/tabulate/__init__.py", line 1516, in _wrap_text_to_colwidths
    str(cell) if _isnumber(cell) else _type(cell, numparse)(cell)
ValueError: invalid literal for int() with base 10: '\x1b[43m\x1b[30m3\x1b[0m'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions