8000 Replaced `type(...)` and `type(ellipsis)` with `types.EllipsisType` · python/cpython@0a97a88 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a97a88

Browse files
author
Bas van Beek
committed
Replaced type(...) and type(ellipsis) with types.EllipsisType
1 parent 00639fc commit 0a97a88

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Lib/ast.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
:copyright: Copyright 2008 by Armin Ronacher.
2525
:license: Python License.
2626
"""
27+
import types
2728
import sys
2829
from _ast import *
2930
from contextlib import contextmanager, nullcontext
@@ -572,7 +573,7 @@ def __new__(cls, *args, **kwargs):
572573
Str: (str,),
573574
Bytes: (bytes,),
574575
NameConstant: (type(None), bool),
575-
Ellipsis: (type(...),),
576+
Ellipsis: (types.EllipsisType,),
576577
}
577578
_const_types_not = {
578579
Num: (bool,),
@@ -586,7 +587,7 @@ def __new__(cls, *args, **kwargs):
586587
complex: 'Num',
587588
str: 'Str',
588589
bytes: 'Bytes',
589-
type(...): 'Ellipsis',
590+
types.EllipsisType: 'Ellipsis',
590591
}
591592

592593
class slice(AST):

Lib/copy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def _copy_immutable(x):
108108
return x
109109
for t in (type(None), int, float, bool, complex, str, tuple,
110110
bytes, frozenset, type, range, slice, property,
111-
types.BuiltinFunctionType, type(Ellipsis), type(NotImplemented),
112-
types.FunctionType, weakref.ref):
111+
types.BuiltinFunctionType, types.EllipsisType,
112+
type(NotImplemented), types.FunctionType, weakref.ref):
113113
d[t] = _copy_immutable
114114
t = getattr(types, "CodeType", None)
115115
if t is not None:
@@ -182,7 +182,7 @@ def deepcopy(x, memo=None, _nil=[]):
182182
def _deepcopy_atomic(x, memo):
183183
return x
184184
d[type(None)] = _deepcopy_atomic
185-
d[type(Ellipsis)] = _deepcopy_atomic
185+
d[types.EllipsisType] = _deepcopy_atomic
186186
d[type(NotImplemented)] = _deepcopy_atomic
187187
d[int] = _deepcopy_atomic
188188
d[float] = _deepcopy_atomic

Lib/lib2to3/fixes/fix_types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
'ComplexType' : 'complex',
3131
'DictType': 'dict',
3232
'DictionaryType' : 'dict',
33-
'EllipsisType' : 'type(Ellipsis)',
3433
#'FileType' : 'io.IOBase',
3534
'FloatType': 'float',
3635
'IntType': 'int',

Lib/pickle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
"""
2525

26-
from types import FunctionType
26+
from types import FunctionType, EllipsisType
2727
from copyreg import dispatch_table
2828
from copyreg import _extension_registry, _inverted_registry, _extension_cache
2929
from itertools import islice
@@ -1121,7 +1121,7 @@ def save_type(self, obj):
11211121
return self.save_reduce(type, (None,), obj=obj)
11221122
elif obj is type(NotImplemented):
11231123
return self.save_reduce(type, (NotImplemented,), obj=obj)
1124-
elif obj is type(...):
1124+
elif obj is EllipsisType:
11251125
return self.save_reduce(type, (...,), obj=obj)
11261126
return self.save_global(obj)
11271127

0 commit comments

Comments
 (0)
0