Skip to content

Commit dd71133

Browse files
Appease test_site
1 parent 9eed720 commit dd71133

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Lib/_collections_abc.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
from abc import ABCMeta, abstractmethod
1010
import sys
11-
import types
1211

1312
GenericAlias = type(list[int])
13+
EllipsisType = type(...)
14+
def _f(): pass
15+
FunctionType = type(_f)
16+
1417

1518
__all__ = ["Awaitable", "Coroutine",
1619
"AsyncIterable", "AsyncIterator", "AsyncGenerator",
@@ -418,21 +421,22 @@ class _CallableGenericAlias(GenericAlias):
418421
419422
See :issue:`42195`.
420423
"""
424+
421425
def __new__(cls, *args, **kwargs):
422426
if not isinstance(args, tuple) or len(args) != 2:
423427
raise TypeError("Callable must be used as "
424428
"Callable[[arg, ...], result].")
425429
_typ, _args = args
426-
if not isinstance(_args, (tuple, types.EllipsisType)) or len(_args) != 2:
430+
if not isinstance(_args, (tuple, EllipsisType)) or len(_args) != 2:
427431
raise TypeError("Callable must be used as "
428432
"Callable[[arg, ...], result].")
429433
t_args, t_result = _args
430-
if not isinstance(t_args, (list, types.EllipsisType)):
434+
if not isinstance(t_args, (list, EllipsisType)):
431435
raise TypeError("Callable[args, result]: args must be a list. Got"
432436
f" {_type_repr(t_args)}")
433437

434438
ga_args = []
435-
for arg in args[1]:
439+
for arg in _args:
436440
if isinstance(arg, list):
437441
ga_args.extend(arg)
438442
else:
@@ -459,7 +463,7 @@ def __repr__(self):
459463
args = f"{', '.join(_type_repr(a) for a in t_args)}"
460464
result = _type_repr(t_result)
461465

462-
if not isinstance(t_args[0], types.EllipsisType):
466+
if not isinstance(t_args[0], EllipsisType):
463467
args = f"[{args}]"
464468

465469
return f"{orig}[{args}, {result}]"
@@ -481,7 +485,7 @@ def _type_repr(obj):
481485
return f'{obj.__module__}.{obj.__qualname__}'
482486
if obj is ...:
483487
return('...')
484-
if isinstance(obj, types.FunctionType):
488+
if isinstance(obj, FunctionType):
485489
return obj.__name__
486490
return repr(obj)
487491

0 commit comments

Comments
 (0)