Skip to content

Commit cba3a90

Browse files
Fix "accepts only single type" errors (#1130)
- Add "a" to make the message grammatical - Add a trailing period because _type_check adds another sentence after it. For example, `Unpack[3]` on 3.10 currently fails with `TypeError: Unpack accepts only single type Got 3.`. - Use an f-string
1 parent 9169152 commit cba3a90

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

typing_extensions/src/typing_extensions.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def __repr__(self):
157157

158158
def __getitem__(self, parameters):
159159
item = typing._type_check(parameters,
160-
f'{self._name} accepts only single type')
160+
f'{self._name} accepts only a single type.')
161161
return typing._GenericAlias(self, (item,))
162162

163163
Final = _FinalForm('Final',
@@ -1336,7 +1336,7 @@ def is_str(val: Union[str, float]):
13361336
``TypeGuard`` also works with type variables. For more information, see
13371337
PEP 647 (User-Defined Type Guards).
13381338
"""
1339-
item = typing._type_check(parameters, f'{self} accepts only single type.')
1339+
item = typing._type_check(parameters, f'{self} accepts only a single type.')
13401340
return typing._GenericAlias(self, (item,))
13411341
# 3.7-3.8
13421342
else:
@@ -1539,7 +1539,7 @@ class Movie(TypedDict, total=False):
15391539
There is no runtime checking that a required key is actually provided
15401540
when instantiating a related TypedDict.
15411541
"""
1542-
item = typing._type_check(parameters, f'{self._name} accepts only single type')
1542+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
15431543
return typing._GenericAlias(self, (item,))
15441544

15451545
@_ExtensionsSpecialForm
@@ -1556,7 +1556,7 @@ class Movie(TypedDict):
15561556
year=1999,
15571557
)
15581558
"""
1559-
item = typing._type_check(parameters, f'{self._name} accepts only single type')
1559+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
15601560
return typing._GenericAlias(self, (item,))
15611561

15621562
else:
@@ -1566,7 +1566,7 @@ def __repr__(self):
15661566

15671567
def __getitem__(self, parameters):
15681568
item = typing._type_check(parameters,
1569-
'{} accepts only single type'.format(self._name))
1569+
f'{self._name} accepts only a single type.')
15701570
return typing._GenericAlias(self, (item,))
15711571

15721572
Required = _RequiredForm(
@@ -1622,7 +1622,7 @@ def add_batch_axis(
16221622
) -> Array[Batch, Unpack[Shape]]: ...
16231623
16241624
"""
1625-
item = typing._type_check(parameters, f'{self._name} accepts only single type')
1625+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
16261626
return _UnpackAlias(self, (item,))
16271627

16281628
def _is_unpack(obj):
@@ -1638,7 +1638,7 @@ def __repr__(self):
16381638

16391639
def __getitem__(self, parameters):
16401640
item = typing._type_check(parameters,
1641-
f'{self._name} accepts only single type')
1641+
f'{self._name} accepts only a single type.')
16421642
return _UnpackAlias(self, (item,))
16431643

16441644
Unpack = _UnpackForm(

0 commit comments

Comments
 (0)