From 2a7427c5c8eda39ab40a0bde6f38f3a9a66f9f0a Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Sat, 22 Apr 2023 14:13:58 -0400 Subject: [PATCH] Make Pyright happy with EnhancedDirectoryTree scrolling - Don't use a lambda so it doesn't return something - Assert region is found (not None) --- enhanced_directory_tree.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/enhanced_directory_tree.py b/enhanced_directory_tree.py index 50f9fb3..ca6066b 100644 --- a/enhanced_directory_tree.py +++ b/enhanced_directory_tree.py @@ -49,4 +49,8 @@ class EnhancedDirectoryTree(DirectoryTree): # Ugh. OK, I'm going to use some internals, and replicate how scroll_to_node works. # self.scroll_to_region(self._get_label_region(node._line), animate=False, top=True) # Timer is needed to wait for the new nodes to mount, I think. - self.set_timer(0.01, lambda: self.scroll_to_region(self._get_label_region(node._line), animate=False, top=True)) + def scroll_node_to_top(): + region = self._get_label_region(node._line) + assert region, "Node not found in tree" + self.scroll_to_region(region, animate=False, top=True) + self.set_timer(0.01, scroll_node_to_top)