From e3899c0c106147e8e67845b8be1942bab579c141 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 16 Nov 2022 15:41:48 +0000 Subject: [PATCH] Check button variant for validity during button construction See #1189 --- CHANGELOG.md | 1 + src/textual/widgets/_button.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2fdb3318..c217b6999c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Watchers are now called immediately when setting the attribute if they are synchronous. https://github.com/Textualize/textual/pull/1145 - Widget.call_later has been renamed to Widget.call_after_refresh. +- Button variant values are now checked at runtime. https://github.com/Textualize/textual/issues/1189 ### Fixed diff --git a/src/textual/widgets/_button.py b/src/textual/widgets/_button.py index b394762d82..aa0f476fc3 100644 --- a/src/textual/widgets/_button.py +++ b/src/textual/widgets/_button.py @@ -186,7 +186,7 @@ def __init__( if disabled: self.add_class("-disabled") - self.variant = variant + self.variant = self.validate_variant(variant) label: Reactive[RenderableType] = Reactive("") variant = Reactive.init("default")