Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when loading null column #265

Closed
sjdurfey opened this issue Oct 8, 2023 · 5 comments · Fixed by tconbeer/textual-fastdatatable#7 or #266
Closed

TypeError when loading null column #265

sjdurfey opened this issue Oct 8, 2023 · 5 comments · Fixed by tconbeer/textual-fastdatatable#7 or #266
Labels
bug Something isn't working

Comments

@sjdurfey
Copy link

sjdurfey commented Oct 8, 2023

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.

@tconbeer
Copy link
Owner

tconbeer commented Oct 8, 2023

Thanks for the report. Should be an easy fix early next week

@tconbeer
Copy link
Owner

tconbeer commented Oct 8, 2023

Also if you downgrade to 1.0.1 you should be good.

@tconbeer tconbeer changed the title TypeError when reading from CSV file TypeError when loading null column Oct 9, 2023
@tconbeer
Copy link
Owner

tconbeer commented Oct 9, 2023

Can repro with both:

select null

and

select null as foo

@tconbeer
Copy link
Owner

tconbeer commented Oct 9, 2023

@sjdurfey this has been patched in v1.1.1 -- thanks so much for the report, turns out there were quite a few scenarios that could have caused this.

@tconbeer tconbeer added the bug Something isn't working label Oct 9, 2023
@sjdurfey
Copy link
Author

sjdurfey commented Oct 9, 2023

@tconbeer, np! Glad it was a quick/easy fix for you. I appreciate it!

edit: I deleted my original comment because I accidentally made it under my work login

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants