Skip to content

Commit 16f83ee

Browse files
committed
Improve the error message when missing an annotation
1 parent 8a46f3f commit 16f83ee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/functools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,8 @@ def register(cls, func=None, _func_is_method=False):
10031003
except KeyError:
10041004
raise TypeError(
10051005
f"Invalid first argument to `register()`: {func!r}. "
1006-
f"Add missing type annotation to parameter {argname!r} "
1007-
"of this function or use `@register(some_class)`."
1006+
"Use either `@register(some_class)` or add a type "
1007+
f"annotation to parameter {argname!r} of your callable."
10081008
) from None
10091009

10101010
if not _is_valid_dispatch_type(cls):

Lib/test/test_functools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,8 +3263,8 @@ def _(arg, extra: int):
32633263
"<function TestSingleDispatch.test_invalid_registrations.<locals>._"
32643264
)
32653265
self.assertEndsWith(str(exc.exception),
3266-
"Add missing type annotation to parameter 'arg' "
3267-
"of this function or use `@register(some_class)`.")
3266+
"Use either `@register(some_class)` or add a type annotation "
3267+
f"to parameter 'arg' of your callable.")
32683268

32693269
with self.assertRaises(TypeError) as exc:
32703270
@i.register

0 commit comments

Comments
 (0)