8000 Remove temporary builtins exception · python/typing@84010fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 84010fe

Browse files
committed
Remove temporary builtins exception
1 parent fd4a1b0 commit 84010fe

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/test2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import *
2+
3+
alpha = TypeVar('alpha')
4+
beta = TypeVar('beta')
5+
6+
X = TypeVar('X')
7+
8+
class ABTuple(Generic[alpha, beta]):
9+
def __init__(self, a : alpha, b : beta):
10+
self.value = (a, b)
11+
12+
IntXTuple = ABTuple[int, X]
13+
IntIntTuple = IntXTuple[int]
14+

src/typing.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ def __new__(cls, name, bases, namespace,
10071007
", ".join(str(g) for g in gvars)))
10081008
tvars = gvars
10091009

1010-
if extra and extra not in bases and extra.__module__ != 'builtins':
1010+
if extra and extra not in bases:
10111011
bases = (extra,) + bases
10121012
self = super().__new__(cls, name, bases, namespace, _root=True)
10131013
self.__parameters__ = tvars
@@ -1542,7 +1542,7 @@ class ByteString(Sequence[int], extra=collections_abc.ByteString):
15421542
ByteString.register(type(memoryview(b'')))
15431543

15441544

1545-
class List(list, MutableSequence[T], extra=list):
1545+
class List(MutableSequence[T], extra=list):
15461546

15471547
def __new__(cls, *args, **kwds):
15481548
if _geqv(cls, List):
@@ -1551,7 +1551,7 @@ def __new__(cls, *args, **kwds):
15511551
return list.__new__(cls, *args, **kwds)
15521552

15531553

1554-
class Set(set, MutableSet[T], extra=set):
1554+
class Set(MutableSet[T], extra=set):
15551555

15561556
def __new__(cls, *args, **kwds):
15571557
if _geqv(cls, Set):
@@ -1560,7 +1560,7 @@ def __new__(cls, *args, **kwds):
15601560
return set.__new__(cls, *args, **kwds)
15611561

15621562

1563-
class FrozenSet(frozenset, AbstractSet[T_co], extra=frozenset):
1563+
class FrozenSet(AbstractSet[T_co], extra=frozenset):
15641564
__slots__ = ()
15651565

15661566
def __new__(cls, *args, **kwds):
@@ -1596,16 +1596,15 @@ class ContextManager(Generic[T_co], extra=contextlib.AbstractContextManager):
15961596
__all__.append('ContextManager')
15971597

15981598

1599-
class Dict(dict, MutableMapping[KT, VT], extra=dict):
1599+
class Dict(MutableMapping[KT, VT], extra=dict):
16001600

16011601
def __new__(cls, *args, **kwds):
16021602
if _geqv(cls, Dict):
16031603
raise TypeError("Type Dict cannot be instantiated; "
16041604
"use dict() instead")
16051605
return dict.__new__(cls, *args, **kwds)
16061606

1607-
class DefaultDict(collections.defaultdict, MutableMapping[KT, VT],
1608-
extra=collections.defaultdict):
1607+
class DefaultDict(MutableMapping[KT, VT], extra=collections.defaultdict):
16091608

16101609
def __new__(cls, *args, **kwds):
16111610
if _geqv(cls, DefaultDict):

0 commit comments

Comments
 (0)
0