Title: type error when using maxcolwidths with colored strings · Issue #359 · astanin/python-tabulate · GitHub
Open Graph Title: type error when using maxcolwidths with colored strings · Issue #359 · astanin/python-tabulate
X Title: type error when using maxcolwidths with colored strings · Issue #359 · astanin/python-tabulate
Description: 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 av...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/astanin/python-tabulate/issues/359
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"type error when using maxcolwidths with colored strings","articleBody":"Issue: colored string type throwing an error in casted_cell assignment because _type method not equipped to handle it. \nCan we either: \n\n- 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. \n- 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\n\n```\ninput value for 'cell': \"3\" (colored string)\nError: \n 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\n str(cell) if _isnumber(cell) else _type(cell, numparse)(cell)\nValueError: invalid literal for int() with base 10: '\\x1b[43m\\x1b[30m3\\x1b[0m'\n```","author":{"url":"https://github.com/Camyll","@type":"Person","name":"Camyll"},"datePublished":"2025-02-12T23:09:30Z","url":"https://github.com/astanin/python-tabulate/issues/359"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9c26257d-97c5-ce3b-9e47-516587f2a0cf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98EA:3A2D2D:7E1100:AC66A2:6AFF382A |
| html-safe-nonce | c050d5512b8562552ced9bdbad6c658ded11dae2eb8c332c6716946dcb158d3c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEVBOjNBMkQyRDo3RTExMDA6QUM2NkEyOjZBRkYzODJBIiwidmlzaXRvcl9pZCI6IjQ1MjQyMDA0Mzk4MDA4NzA5NTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 357fa77169934148c75a1c7892d2bc433946ee170a7371c5f9f55e40e53248e9 |
| hovercard-subject-tag | issue:2849543918 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/astanin/python-tabulate/359/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bcb990f7cbfe13e8d0e8846b2db900c3a6102232a09061f36a4f4d610740fb16/astanin/python-tabulate/issues/359 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bcb990f7cbfe13e8d0e8846b2db900c3a6102232a09061f36a4f4d610740fb16/astanin/python-tabulate/issues/359 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Camyll |
| hostname | github.com |
| expected-hostname | github.com |
| None | c62a4cffe270f7bba529ed9ad80c801130bd3c78e2633b6731e04c3d4c94463b |
| turbo-cache-control | no-preview |
| go-import | github.com/astanin/python-tabulate git https://github.com/astanin/python-tabulate.git |
| octolytics-dimension-user_id | 71802 |
| octolytics-dimension-user_login | astanin |
| octolytics-dimension-repository_id | 205875548 |
| octolytics-dimension-repository_nwo | astanin/python-tabulate |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 205875548 |
| octolytics-dimension-repository_network_root_nwo | astanin/python-tabulate |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1a7765b21f802bf37d4363105328933cfb777dff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width