Skip to content

Commit 5010db7

Browse files
authored
More consistent error messages
1 parent 6f71ba4 commit 5010db7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mypy/stubtest.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ def verify_typealias(
10221022
if not isinstance(runtime_type, type):
10231023
yield Error(
10241024
object_path, "is inconsistent: runtime is not a type", stub, runtime,
1025-
stub_desc=str(stub_target)
1025+
stub_desc=f"Type alias for: {stub_target}"
10261026
)
10271027
return
10281028
# Don't test the fullname,
@@ -1038,7 +1038,9 @@ def verify_typealias(
10381038
f"is inconsistent: runtime is an alias for {runtime_name} "
10391039
f"but stub is an alias for {stub_name}"
10401040
)
1041-
yield Error(object_path, msg, stub, runtime, stub_desc=str(stub_target))
1041+
yield Error(
1042+
object_path, msg, stub, runtime, stub_desc=f"Type alias for: {stub_target}"
1043+
)
10421044
return
10431045
if isinstance(stub_target, mypy.types.UnionType):
10441046
if sys.version_info >= (3, 10) and isinstance(runtime, types.UnionType):
@@ -1051,7 +1053,7 @@ def verify_typealias(
10511053
if tuple not in getattr(runtime, "__mro__", getattr(get_origin(runtime), "__mro__", ())):
10521054
yield Error(
10531055
object_path, "is not a subclass of tuple", stub, runtime,
1054-
stub_desc=str(stub_target)
1056+
stub_desc=f"Type alias for: {stub_target}"
10551057
)
10561058
# could check Tuple contents here...
10571059
return
@@ -1063,10 +1065,11 @@ def verify_typealias(
10631065
return
10641066
yield Error(
10651067
object_path, "is not a type alias for Callable", stub, runtime,
1066-
stub_desc=str(stub_target)
1068+
stub_desc=f"Type alias for: {stub_target}"
10671069
)
10681070
yield Error(
1069-
object_path, "is not a recognised type alias", stub, runtime, stub_desc=str(stub_target)
1071+
object_path, "is not a recognised type alias", stub, runtime,
1072+
stub_desc=f"Type alias for: {stub_target}"
10701073
)
10711074

10721075

0 commit comments

Comments
 (0)