Skip to content

Commit 1f9cd3c

Browse files
Argument Clinic: fix bare "type" in annotations (#112915)
Bare "type" in annotations should be equivalent to "type[Any]"; see https://discuss.python.org/t/inconsistencies-between-type-and-type/37404 and python/mypy#16366. It's better to use "type[object]", which is safer and unambiguous.
1 parent 9d02d34 commit 1f9cd3c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Tools/clinic/clinic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ def closure(f: CConverterClassT) -> CConverterClassT:
31843184

31853185
class CConverterAutoRegister(type):
31863186
def __init__(
3187-
cls, name: str, bases: tuple[type, ...], classdict: dict[str, Any]
3187+
cls, name: str, bases: tuple[type[object], ...], classdict: dict[str, Any]
31883188
) -> None:
31893189
converter_cls = cast(type["CConverter"], cls)
31903190
add_c_converter(converter_cls)
@@ -3217,7 +3217,7 @@ class CConverter(metaclass=CConverterAutoRegister):
32173217

32183218
# If not None, default must be isinstance() of this type.
32193219
# (You can also specify a tuple of types.)
3220-
default_type: bltns.type[Any] | tuple[bltns.type[Any], ...] | None = None
3220+
default_type: bltns.type[object] | tuple[bltns.type[object], ...] | None = None
32213221

32223222
# "default" converted into a C value, as a string.
32233223
# Or None if there is no default.
@@ -3683,7 +3683,7 @@ def add_include(self, name: str, reason: str,
36833683
ReturnConverterDict = dict[str, ReturnConverterType]
36843684
return_converters: ReturnConverterDict = {}
36853685

3686-
TypeSet = set[bltns.type[Any]]
3686+
TypeSet = set[bltns.type[object]]
36873687

36883688

36893689
class bool_converter(CConverter):
@@ -4347,7 +4347,7 @@ class buffer: pass
43474347
class rwbuffer: pass
43484348
class robuffer: pass
43494349

4350-
StrConverterKeyType = tuple[frozenset[type], bool, bool]
4350+
StrConverterKeyType = tuple[frozenset[type[object]], bool, bool]
43514351

43524352
def str_converter_key(
43534353
types: TypeSet, encoding: bool | str | None, zeroes: bool
@@ -4846,7 +4846,7 @@ class CReturnConverterAutoRegister(type):
48464846
def __init__(
48474847
cls: ReturnConverterType,
48484848
name: str,
4849-
bases: tuple[type, ...],
4849+
bases: tuple[type[object], ...],
48504850
classdict: dict[str, Any]
48514851
) -> None:
48524852
add_c_return_converter(cls)

0 commit comments

Comments
 (0)