From a0f837aad71e34b2c74a424edf61acd9fdf40f49 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Sun, 16 Jul 2023 00:59:42 -0400 Subject: [PATCH] Remove unnecessary "type: ignore" comments --- src/textual_paint/auto_restart.py | 8 +++---- src/textual_paint/enhanced_directory_tree.py | 2 +- src/textual_paint/inspector.py | 22 ++++++++++---------- src/textual_paint/paint.py | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/textual_paint/auto_restart.py b/src/textual_paint/auto_restart.py index b9353d6..465e1c6 100644 --- a/src/textual_paint/auto_restart.py +++ b/src/textual_paint/auto_restart.py @@ -68,7 +68,7 @@ class RestartHandler(PatternMatchingEventHandler): return print("Reloading due to FS change:", event.event_type, event.src_path) try: - _app.screen.styles.background = "red" # type: ignore + _app.screen.styles.background = "red" except ScreenStackError: pass # The unsaved changes prompt seems to need call_from_thread, @@ -78,11 +78,11 @@ class RestartHandler(PatternMatchingEventHandler): # However, when _app.action_reload is called from the key binding, # it seems to work fine with or without unsaved changes. if _app.is_document_modified(): - _app.call_from_thread(_app.action_reload) # type: ignore + _app.call_from_thread(_app.action_reload) else: restart_program() try: - _app.screen.styles.background = "yellow" # type: ignore + _app.screen.styles.background = "yellow" except ScreenStackError: pass @@ -108,5 +108,5 @@ def restart_on_changes(app: PaintApp): ], ignore_directories=True, ) - observer.schedule(handler, path='.', recursive=True) # type: ignore + observer.schedule(handler, path='.', recursive=True) observer.start() diff --git a/src/textual_paint/enhanced_directory_tree.py b/src/textual_paint/enhanced_directory_tree.py index 744b7a9..09923a9 100644 --- a/src/textual_paint/enhanced_directory_tree.py +++ b/src/textual_paint/enhanced_directory_tree.py @@ -71,7 +71,7 @@ class EnhancedDirectoryTree(DirectoryTree): # Even though it's the same event, bubbling, the `call_next` # callback actually comes before the event finishes bubbling. # self.call_later(clear_flag) # too early! - self.call_after_refresh(clear_flag) # finally reliable # type: ignore + self.call_after_refresh(clear_flag) # finally reliable def _expand_matching_child(self, node: TreeNode[DirEntry], remaining_parts: tuple[str], callback: Callable[[], None]) -> None: """Hooks into DirectoryTree's add method, and expands the child node matching the next path part, recursively. diff --git a/src/textual_paint/inspector.py b/src/textual_paint/inspector.py index 05212e1..7684dc5 100644 --- a/src/textual_paint/inspector.py +++ b/src/textual_paint/inspector.py @@ -719,7 +719,7 @@ class NodeInfo(Container): # TODO: toggle rules # TODO: add new rules - stylesheet = dom_node.app.stylesheet # type: ignore + stylesheet = dom_node.app.stylesheet rule_sets = stylesheet.rules applicable_rule_sets: list[RuleSet] = [] for rule_set in rule_sets: @@ -1039,7 +1039,7 @@ class NodeInfo(Container): def _get_rule_at(self, x: int, y: int) -> str | None: """Return the rule (property name) at the given absolute position, or None.""" try: - style = self.screen.get_style_at(x, y) # type: ignore + style = self.screen.get_style_at(x, y) except NoWidget: # shouldn't really happen return None if "rule" in style.meta: @@ -1049,14 +1049,14 @@ class NodeInfo(Container): def on_mouse_down(self, event: events.MouseDown) -> None: """Select a rule to edit.""" - widget, _ = self.screen.get_widget_at(*event.screen_offset) # type: ignore + widget, _ = self.screen.get_widget_at(*event.screen_offset) if widget is self._style_value_input: return self._apply_style_value() x, y = event.screen_offset rule = self._get_rule_at(x, y) if rule is not None: - meta = self.screen.get_style_at(*event.screen_offset).meta # type: ignore + meta = self.screen.get_style_at(*event.screen_offset).meta assert "value" in meta, "Style meta has rule without value" assert "inline" in meta, "Style meta has rule without inline bool" if not meta["inline"]: @@ -1174,7 +1174,7 @@ class ResizeHandle(Widget): self._start_mouse_position: Offset | None = None self._side: Literal["left", "right", "top", "bottom"] = side self._horizontal_resize = side in ("left", "right") - self.styles.dock = side # type: ignore + self.styles.dock = side def on_mouse_down(self, event: events.MouseDown) -> None: if self.disabled or self._resizing: @@ -1318,7 +1318,7 @@ class Inspector(Container): def get_widget_under_mouse(self, screen_offset: Offset) -> Widget | None: """Get the widget under the mouse, ignoring the inspector's highlights and (optionally) the inspector panel.""" - for widget, _ in self.screen.get_widgets_at(*screen_offset): # type: ignore + for widget, _ in self.screen.get_widgets_at(*screen_offset): if widget.has_class("inspector_highlight") or ( self in widget.ancestors_with_self and not ALLOW_INSPECTING_INSPECTOR ): @@ -1458,8 +1458,8 @@ class Inspector(Container): # Highlight the clipped region of the hovered widget. # TODO: Highlight the metrics of the hovered widget: padding, border, margin. - if "inspector_highlight" not in self.app.styles.layers: # type: ignore - self.app.styles.layers += ("inspector_highlight",) # type: ignore + if "inspector_highlight" not in self.app.styles.layers: + self.app.styles.layers += ("inspector_highlight",) if dom_node not in self._highlight_boxes: self._highlight_boxes[dom_node] = {} @@ -1482,14 +1482,14 @@ class Inspector(Container): # box.styles.dock = "top" # "Literal['top']" is incompatible with "str | None" # box.styles.dock = cast(str, "top") # "str" is incompatible with "str | None" # box.styles.dock = cast(str | None, "top") # "str | None" is incompatible with "str | None" - box.styles.dock = "top" # type: ignore - self.app.mount(box) # type: ignore + box.styles.dock = "top" + self.app.mount(box) used_boxes.append(box) # show_box("region", dom_node.region, "blue") # show_box("scrollable_content_region", dom_node.scrollable_content_region, "red") try: - map_geometry = self.screen.find_widget(dom_node) # type: ignore + map_geometry = self.screen.find_widget(dom_node) except NoWidget: return # Show the hovered widget's region, as it extends OUTSIDE of the clip region diff --git a/src/textual_paint/paint.py b/src/textual_paint/paint.py index 6376ed1..28e4e76 100755 --- a/src/textual_paint/paint.py +++ b/src/textual_paint/paint.py @@ -160,7 +160,7 @@ class MetaGlyphFont: fig.font = self.file_path # may not be used fig.Font = fig_font # this feels so wrong for char in self.covered_characters: - meta_glyph = fig.renderText(char) # type: ignore + meta_glyph = fig.renderText(char) self.glyphs[char] = meta_glyph.split("\n") covered_characters = R""" !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""