Pressing enter in a DataTable with rows but no columns raises `CellDoesNotExist`
まだ誰も着手していません。
評価
調査の方向性
textual/widgets/_data_table.py の _post_selected_message から始めて、既存の行がない場合の早期リターンを、ここで説明している列がない場合と比較してください。行はあるが列がない状態で Enter を押す場合のテストを追加してください。カーソルの種類 row と column も含めてください。例外が発生せず、空のテーブルでの動作が維持されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi! I hit this while writing generated tests against Textual's widgets. If a DataTable has rows but no columns yet (for example, rows added before the columns), pressing enter crashes the app.
from textual.app import App, ComposeResult
from textual.widgets import DataTable
class NoColumnsApp(App):
def compose(self) -> ComposeResult:
yield DataTable()
def on_mount(self) -> None:
table = self.query_one(DataTable)
table.add_row()
table.focus()
if __name__ == "__main__":
NoColumnsApp().run() # then press enter
Expected: nothing happens, as with an empty table.
Actual (on Textual 8.2.7, and main at 5e5b7ef):
File "textual/widgets/_data_table.py", line 2839, in action_select_cursor
self._post_selected_message()
File "textual/widgets/_data_table.py", line 2847, in _post_selected_message
cell_key = self.coordinate_to_cell_key(cursor_coordinate)
File "textual/widgets/_data_table.py", line 1291, in coordinate_to_cell_key
raise CellDoesNotExist(f"No cell exists at {coordinate!r}.")
textual.widgets._data_table.CellDoesNotExist: No cell exists at Coordinate(row=0, column=0).
The same happens with cursor_type set to "row" or "column". _post_selected_message already returns early when there are no rows (the fix for #1970); it doesn't check for columns.
I'd suggest returning early when there are no columns as well. For the row cursor you could argue a RowSelected should still be posted, but that would need a cell key without a column, so returning early seemed the smaller change. I'm happy to send a PR.
- 主要言語
- Python
- スター
- 37.7k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Textualize/textual のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6790 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
Textualize/textual#6789 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6787 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Textualize/textual#6782 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Textualize/textual#6778 · コメント 1 件 ·
Textualize/textual の issue をすべて見る
似ている issue
-
Internal Errorオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
frappe/frappe_docker#2071 ·
メンテナーはふだん 1 日以内に返信
-
bug python
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
traceloop/openllmetry#4717 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
The-Pocket/PocketFlow#161 ·
-
comp/desktop P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#157702 ·
メンテナーはふだん 1 日以内に返信
-
scibench_physics / scibench_chemistry: a correct answer scores 0 when the unit has a power of ten対応中かも @BahaaMattar が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
EvolvingLMMs-Lab/lmms-eval#1699 ·
メンテナーはふだん 1 日以内に返信