Skip to content

Commit 8d599f9

Browse files
committed
error messages
1 parent b664391 commit 8d599f9

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/textual/css/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def first(
242242
if expect_type is not None:
243243
if not isinstance(first, expect_type):
244244
raise WrongType(
245-
f"Query value is wrong type; expected {expect_type}, got {type(first)}"
245+
f"Query value is the wrong type; expected {expect_type}, found {first}"
246246
)
247247
return first
248248
else:
@@ -324,7 +324,7 @@ def last(
324324
last = self.nodes[-1]
325325
if expect_type is not None and not isinstance(last, expect_type):
326326
raise WrongType(
327-
f"Query value is wrong type; expected {expect_type}, got {type(last)}"
327+
f"Query value is the wrong type; expected {expect_type}, found {last}"
328328
)
329329
return last
330330

src/textual/getters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def __get__(
181181
raise NoMatches(f"No child found with id={self.child_id!r}")
182182
if not isinstance(child, self.expect_type):
183183
raise WrongType(
184-
f"Child with id={id!r} is wrong type; expected {self.expect_type}, got"
185-
f" {type(child)}"
184+
f"Child with id={id!r} is the wrong type; expected type {self.expect_type}, found {child}"
186185
)
187186
return child

src/textual/widget.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,7 @@ def get_child_by_id(
10051005
return child
10061006
if not isinstance(child, expect_type):
10071007
raise WrongType(
1008-
f"Child with id={id!r} is wrong type; expected {expect_type}, got"
1009-
f" {type(child)}"
1008+
f"Child with id={id!r} is the wrong type; expected type {expect_type}, found {child}"
10101009
)
10111010
return child
10121011

@@ -1042,8 +1041,7 @@ def get_widget_by_id(
10421041
widget = self.query_one(f"#{id}")
10431042
if expect_type is not None and not isinstance(widget, expect_type):
10441043
raise WrongType(
1045-
f"Descendant with id={id!r} is wrong type; expected {expect_type},"
1046-
f" got {type(widget)}"
1044+
f"Descendant with id={id!r} is the wrong type; expected {expect_type}, found {widget}"
10471045
)
10481046
return widget
10491047

0 commit comments

Comments
 (0)