From b3b98f1089589e0be63038ce6bf4a6ee0af342e4 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Sun, 7 May 2023 18:11:14 +0100 Subject: [PATCH] Simplify the adding of genuine options Extending a list with an empty list is petty much a no-op so don't bother to faff around testing for what Python will be testing for anyway. --- src/textual/widgets/_option_list.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/textual/widgets/_option_list.py b/src/textual/widgets/_option_list.py index f72c8b7d8..dba669592 100644 --- a/src/textual/widgets/_option_list.py +++ b/src/textual/widgets/_option_list.py @@ -528,9 +528,7 @@ class OptionList(ScrollView, can_focus=True): self._contents.extend(content) # Pull out the content that is genuine options and add them to the # list of options. - options = [item for item in content if isinstance(item, Option)] - if options: - self._options.extend(options) + self._options.extend([item for item in content if isinstance(item, Option)]) self._refresh_content_tracking(force=True) self.refresh() return self