question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button variant="disabled" gives type hinting error

See original GitHub issue

Here’s a sample program to reproduce the issue:

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

class MinimalApp(App):

    def compose(self) -> ComposeResult:
        yield Button(variant="disabled")

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

Here’s the error I get:

$ mypy minimal.py 
minimal.py:7: error: Argument "variant" to "Button" has incompatible type "Literal['disabled']"; expected "Literal['default', 'primary', 'success', 'warning', 'error']"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

Looking through https://github.com/Textualize/textual/blob/main/src/textual/widgets/_button.py, seems like the disabled variant is missing here:

ButtonVariant = Literal["default", "primary", "success", "warning", "error"]
_VALID_BUTTON_VARIANTS = {"default", "primary", "success", "warning", "error"}

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
davepcommented, Nov 16, 2022

Just to update: as from the next release this will raise an exception at runtime.

1reaction
learnbyexamplecommented, Nov 16, 2022

Thanks for the explanation and the sample code (in which I also learned that CSS can be assigned in the code itself).

I’ll close this issue as my code now correctly uses disabled=True, thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frustrating Design Patterns: Disabled Buttons
With disabled buttons, because the rest of the interface is accessible, users seem to have more confidence that there is a problem directly ......
Read more >
Cannot invoke an object which is possibly 'undefined'.ts(2722)
There are two approached to a fix: one is to keep ButtonProps the same with onClick as optional, and to check that onClick...
Read more >
React with TypeScript Cheatsheet - Bits and Pieces
TypeScript will throw a static error when the value of priority or score prop above doesn't match any of the literal values. Next,...
Read more >
Template type checking - Angular
If the consumer has Angular's strictest type checking for templates enabled, this creates a problem: the empty string ( '' ) is not...
Read more >
<input>: The Input (Form Input) element - HTML
See the file input type. alt. Valid for the image button only, the alt attribute provides alternative text for the image, displaying the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found