Skip to content

Commit 065a032

Browse files
committed
Better way to fix test_site.py: don't import types from collections
1 parent 2b22f6e commit 065a032

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

Lib/_collections_abc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from abc import ABCMeta, abstractmethod
1010
import sys
11-
from types import GenericAlias
11+
12+
GenericAlias = type(list[int])
1213

1314
__all__ = ["Awaitable", "Coroutine",
1415
"AsyncIterable", "AsyncIterator", "AsyncGenerator",

Lib/collections/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from _weakref import proxy as _proxy
2626
from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
2727
from reprlib import recursive_repr as _recursive_repr
28-
from types import GenericAlias as _GenericAlias
2928

3029
try:
3130
from _collections import deque
@@ -39,6 +38,8 @@
3938
except ImportError:
4039
pass
4140

41+
_GenericAlias = type(list[int])
42+
4243

4344
################################################################################
4445
### OrderedDict

Lib/test/test_site.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def test_startup_imports(self):
537537
# http://bugs.python.org/issue19218
538538
collection_mods = {'_collections', 'collections', 'functools',
539539
'heapq', 'itertools', 'keyword', 'operator',
540-
'reprlib', 'weakref'
540+
'reprlib', 'types', 'weakref'
541541
}.difference(sys.builtin_module_names)
542542
self.assertFalse(modules.intersection(collection_mods), stderr)
543543

0 commit comments

Comments
 (0)