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

Removing a widget using remove() generates "Task exception was never retrieved" (app works fine) #2079

Closed
learnbyexample opened this issue Mar 16, 2023 · 2 comments · Fixed by #2080
Labels
bug Something isn't working

Comments

@learnbyexample
Copy link
Contributor

Here's a minimal test app:

from textual.app import App
from textual.widgets import Label, Button

class TestApp(App):

    def compose(self):
        yield Button('Click me')

    def on_mount(self):
        self.dark = False

    def on_button_pressed(self, event):
        w = Label()
        w.remove()

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

For Textual 0.15.0 version, I'm getting the following report on the terminal (after closing the app). This seems to happen only when remove() is encountered. So, if you run the above app without clicking the button, the error message doesn't appear.

(virt_env) $ python test_app.py
Task exception was never retrieved
future: <Task finished name='prune nodes' coro=<App._remove_nodes.<locals>.prune_widgets_task() done, defined at /home/learnbyexample/virt_env/lib/python3.8/site-packages/textual/app.py:2187> exception=AttributeError("'NoneType' object has no attribute 'styles'")>
Traceback (most recent call last):
  File "/home/learnbyexample/virt_env/lib/python3.8/site-packages/textual/app.py", line 2200, in prune_widgets_task
    if parent.styles.auto_dimensions:
AttributeError: 'NoneType' object has no attribute 'styles'

For the actual app I'm working on, I haven't observed any issue due to this error.

@github-actions
Copy link

We found the following entries 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

@willmcgugan willmcgugan added the bug Something isn't working label Mar 16, 2023
@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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
Development

Successfully merging a pull request may close this issue.

2 participants