Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
25.62k stars 788 forks source link

Crash when instancing a SelectionList with disabled=True #5028

Closed dmunozv04 closed 1 month ago

dmunozv04 commented 1 month ago

Have you checked closed issues? https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed Yes

Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug.

Attempting to instance a SelectionList with the argument disabled=True will crash Textual. This change seems to have been introduced in v0.71 since I'm unable to replicate it on v0.70 or previous versions. I've attached the full crash log as well as a minimal python script that replicates the issue described.

from textual.app import App
from textual.widgets import SelectionList

class TestApp(App):
    def compose(self):
        yield SelectionList(
            ("Simple SelectionList", "", False), # Doesn't even need to have options to crash
            disabled=True
        )

app = TestApp()
app.run()

error.txt

Please do let me know if you need anything else from me

It will be helpful if you run the following command and paste the results:

Textual Diagnostics

Versions

Name Value
Textual 0.79.1
Rich 13.8.1

Python

Name Value
Version 3.12.6
Implementation CPython
Compiler Clang 15.0.0 (clang-1500.3.9.4)
Executable /Users/david/Documents/GitHub/iSponsorBlockTV/.venv/bin/python3.12

Operating System

Name Value
System Darwin
Release 24.0.0
Version Darwin Kernel Version 24.0.0: Mon Aug 12 20:51:54 PDT 2024; root:xnu-11215.1.10~2/RELEASE_ARM64_T6000

Terminal

Name Value
Terminal Application vscode (1.93.1)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=100, height=32
legacy_windows False
min_width 1
max_width 100
is_terminal True
encoding utf-8
max_height 32
justify None
overflow None
no_wrap False
highlight None
markup None
height None

If you don't have the textual command on your path, you may have forgotten to install the textual-dev package.

Feel free to add screenshots and / or videos. These can be very helpful!

github-actions[bot] commented 1 month ago

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

TomJGooding commented 1 month ago

It looks like this isn't just an issue with the SelectionList, but other widgets too with a notify_style_update method where their caches haven't yet been initialised.

Should the super() call be moved to last...?

AttributeError: 'DataTable' object has no attribute '_row_render_cache'

from textual.app import App, ComposeResult
from textual.widgets import DataTable

class ExampleApp(App):
    def compose(self) -> ComposeResult:
        yield DataTable(
            disabled=True,
        )

if __name__ == "__main__":
    app = ExampleApp()
    app.run()

AttributeError: 'RichLog' object has no attribute '_line_cache'

from textual.app import App, ComposeResult
from textual.widgets import RichLog

class ExampleApp(App):
    def compose(self) -> ComposeResult:
        yield RichLog(
            disabled=True,
        )

if __name__ == "__main__":
    app = ExampleApp()
    app.run()
github-actions[bot] commented 1 month ago

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

dmunozv04 commented 1 month ago

Thanks for fixing it @willmcgugan !