Button variant="disabled" gives type hinting error
See original GitHub issueHere’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:
- Created 10 months ago
- Comments:8 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to update: as from the next release this will raise an exception at runtime.
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 😃