Skip to content

TypeError when loading null column #265

Closed
tconbeer/textual-fastdatatable
#7
@sjdurfey

Description

I went to do some exploration of a csv file (found here: https://www.retrosheet.org/biofile.htm) and just trying to do a select * from the file caused harlequin to crash with this traceback:

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /Users/user/.pyenv/versions/3.11.4/lib/python3.11/site-packages/textual_fastdatatable/data_table.py:1430 in _on_idle                                                                                                                                             │
│                                                                                                                                                                                                                                                                     │
│   1427 │   │   │   # new_rows = self._new_rows.copy()                                           ╭───────────────── locals ─────────────────╮                                                                                                                        │
│   1428 │   │   │   new_rows: list[int] = []                                                     │        _ = Idle()                        │                                                                                                                        │
│   1429 │   │   │   # self._new_rows.clear()                                                     │ new_rows = []                            │                                                                                                                        │
│ ❱ 1430 │   │   │   self._update_dimensions(new_rows)                                            │     self = ResultsTable(id='t320566635') │                                                                                                                        │
│   1431 │                                                                                        ╰──────────────────────────────────────────╯                                                                                                                        │
│   1432 │   def refresh_coordinate(self, coordinate: Coordinate) -> Self:                                                                                                                                                                                            │
│   1433 │   │   """Refresh the cell at a coordinate.                                                                                                                                                                                                                 │
│                                                                                                                                                                                                                                                                     │
│ /Users/user/.pyenv/versions/3.11.4/lib/python3.11/site-packages/textual_fastdatatable/data_table.py:1115 in _update_dimensions                                                                                                                                   │
│                                                                                                                                                                                                                                                                     │
│   1112 │   │   │   │   │   │   │   ]                                                            ╭─────────────────────────── locals ───────────────────────────╮                                                                                                    │
│   1113 │   │   │   │   │   │   )                                                                │ auto_height_rows = []                                        │                                                                                                    │
│   1114 │   │                                                                                    │          console = <console width=263 ColorSystem.TRUECOLOR> │                                                                                                    │
│ ❱ 1115 │   │   data_cells_width = sum(column.render_width for column in self.ordered_columns)   │         new_rows = []                                        │                                                                                                    │
│   1116 │   │   total_width = data_cells_width + self._row_label_column_width                    │             self = ResultsTable(id='t320566635')             │                                                                                                    │
│   1117 │   │   header_height = self.header_height if self.show_header else 0                    ╰──────────────────────────────────────────────────────────────╯                                                                                                    │
│   1118 │   │   self.virtual_size = Size(                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                                     │
│ /Users/user/.pyenv/versions/3.11.4/lib/python3.11/site-packages/textual_fastdatatable/data_table.py:1115 in <genexpr>                                                                                                                                            │
│                                                                                                                                                                                                                                                                     │
│   1112 │   │   │   │   │   │   │   ]                                                            ╭──────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮                                                 │
│   1113 │   │   │   │   │   │   )                                                                │     .0 = <list_iterator object at 0x133979720>                                                                  │                                                 │
│   1114 │   │                                                                                    │ column = Column(label=<text 'BAT.CHG s' [Span(8, 9, '#888888')]>, width=0, content_width=None, auto_width=True) │                                                 │
│ ❱ 1115 │   │   data_cells_width = sum(column.render_width for column in self.ordered_columns)   ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                 │
│   1116 │   │   total_width = data_cells_width + self._row_label_column_width                                                                                                                                                                                        │
│   1117 │   │   header_height = self.header_height if self.show_header else 0                                                                                                                                                                                        │
│   1118 │   │   self.virtual_size = Size(                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                                     │
│ /Users/user/.pyenv/versions/3.11.4/lib/python3.11/site-packages/textual_fastdatatable/data_table.py:133 in render_width                                                                                                                                          │
│                                                                                                                                                                                                                                                                     │
│    130 │   │   """Width in cells, required to render a column."""                               ╭─────────────────────────────────────────────────── locals ────────────────────────────────────────────────────╮                                                   │
│    131 │   │   # +2 is to account for space padding either side of the cell                     │ self = Column(label=<text 'BAT.CHG s' [Span(8, 9, '#888888')]>, width=0, content_width=None, auto_width=True) │                                                   │
│    132 │   │   if self.auto_width:                                                              ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                   │
│ ❱  133 │   │   │   return max(len(self.label), self.content_width) + CELL_X_PADDING                                                                                                                                                                                 │
│    134 │   │   else:                                                                                                                                                                                                                                                │
│    135 │   │   │   return self.width + CELL_X_PADDING                                                                                                                                                                                                               │
│    136                                                                                                                                                                                                                                                              │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: '>' not supported between instances of 'NoneType' and 'int'

The file appears to be valid. I'm able to open it in a python script, parse it, and write out each row without an error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions