From 247f78d65771fb3e82f278bc887e984a51f1e601 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Mon, 29 May 2023 23:50:19 -0400 Subject: [PATCH] Ignore two type checker errors --- src/textual_paint/inspector.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/textual_paint/inspector.py b/src/textual_paint/inspector.py index 5320cd4..c10be66 100644 --- a/src/textual_paint/inspector.py +++ b/src/textual_paint/inspector.py @@ -368,10 +368,10 @@ class PropertiesTree(Tree[object]): Text.from_markup(f"[b]{escape(name)}[/b]"), Text.from_markup(f"[#808080]({length})[/#808080]"), Text("="), - PropertiesTree.highlighter(repr(data)) + PropertiesTree.highlighter(repr(data)) # type: ignore )) # Can I perhaps DRY with with_name() with with_name taking a length parameter? In other words: - # Can I perhaps DRY with with_name() with with_name() with with_name(text, length) as the parameters? + # Can I maybe DRY this with with_name with with_name with with_name(text, length) as the signature? elif isinstance(data, (str, bytes, int, float, bool, type(None))): node.allow_expand = False node.set_label(with_name(PropertiesTree.highlighter(repr(data)))) @@ -385,7 +385,9 @@ class PropertiesTree(Tree[object]): PropertiesTree.highlighter(str(inspect.signature(data))), )) elif hasattr(data, "__dict__") or hasattr(data, "__slots__") or isinstance(data, dict): - node.set_label(with_name(PropertiesTree.highlighter(repr(data)))) + # Pyright gives an error here due to the more specific "object | dict[Unknown, Unknown]" + # even though object is a superclass of dict and repr takes an object. + node.set_label(with_name(PropertiesTree.highlighter(repr(data)))) # type: ignore else: node.allow_expand = False node.set_label(with_name(PropertiesTree.highlighter(repr(data))))