Skip to content

Commit

Permalink
TypeAliasType: Add apostrophe to error message for compatibility with…
Browse files Browse the repository at this point in the history
… CPython (#495)
  • Loading branch information
Daraan authored Oct 25, 2024
1 parent a506398 commit 9340ce7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7463,9 +7463,9 @@ def test_type_params_possibilities(self):
(T_default, P_default, Ts_default),
]
invalid_cases = [
((T_default, T), f"non-default type parameter {T!r} follows default"),
((P_default, P), f"non-default type parameter {P!r} follows default"),
((Ts_default, T), f"non-default type parameter {T!r} follows default"),
((T_default, T), f"non-default type parameter '{T!r}' follows default"),
((P_default, P), f"non-default type parameter '{P!r}' follows default"),
((Ts_default, T), f"non-default type parameter '{T!r}' follows default"),
# Only type params are accepted
((1,), "Expected a type param, got 1"),
((str,), f"Expected a type param, got {str!r}"),
Expand Down
4 changes: 2 additions & 2 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3622,8 +3622,8 @@ def __init__(self, name: str, value, *, type_params=()):
getattr(type_param, '__default__', NoDefault) is not NoDefault
)
if default_value_encountered and not has_default:
raise TypeError(f'non-default type parameter {type_param!r}'
' follows default type parameter')
raise TypeError(f"non-default type parameter '{type_param!r}'"
" follows default type parameter")
if has_default:
default_value_encountered = True
if isinstance(type_param, TypeVarTuple):
Expand Down

0 comments on commit 9340ce7

Please sign in to comment.