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

Confusing ValueError: No Tab with id 'tab-1' when a NoMatches is expected #2480

Closed
barisione opened this issue May 4, 2023 · 3 comments · Fixed by #2554
Closed

Confusing ValueError: No Tab with id 'tab-1' when a NoMatches is expected #2480

barisione opened this issue May 4, 2023 · 3 comments · Fixed by #2554

Comments

@barisione
Copy link

Querying a non existing ID in an app using TabbedCotent causes a confusing error:

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


class MyApp(App):
    def compose(self) -> ComposeResult:
        with containers.Vertical():
            with widgets.TabbedContent():
                with widgets.TabPane("List #1"):
                    yield widgets.ListView(id="foo")

    def on_ready(self) -> None:
        self.query_one(f"#bar")  # Note the wrong ID.


MyApp().run()

This gives me ValueError: No Tab with id 'tab-1'. If you scroll up you can see NoMatches: No nodes match but it's confusing and sort of hidden.

Textual Diagnostics

Versions

Name Value
Textual 0.23.0
Rich 13.3.5

Python

Name Value
Version 3.10.1
Implementation CPython
Compiler Clang 13.0.0 (clang-1300.0.29.30)
Executable /Users/bari/.pyenv/versions/3.10.1/envs/undo-core-venv3.10/bin/python3.10

Operating System

Name Value
System Darwin
Release 21.6.0
Version Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64

Terminal

Name Value
Terminal Application iTerm.app (3.5.0beta10)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=238, height=62
legacy_windows False
min_width 1
max_width 238
is_terminal True
encoding utf-8
max_height 62
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@github-actions
Copy link

github-actions bot commented May 4, 2023

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@barisione barisione changed the title Confusing `ValueError: No Tab with id 'tab-1' when a NoMatches is expected Confusing ValueError: No Tab with id 'tab-1' when a NoMatches is expected May 4, 2023
@TomJGooding
Copy link
Contributor

Sorry, just totally ignore my previous PR!

If you comment out the container, this returns the NoMatches error as expected. Not really sure why yet, but posting in case it helps someone smarter to debug this!

@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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants