mirror of
https://github.com/python/cpython.git
synced 2025-09-29 11:45:57 +00:00
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.
This commit is contained in:
parent
9d02d3451a
commit
1f9cd3c1e5
1 changed files with 5 additions and 5 deletions
|
@ -3184,7 +3184,7 @@ def add_legacy_c_converter(
|
||||||
|
|
||||||
class CConverterAutoRegister(type):
|
class CConverterAutoRegister(type):
|
||||||
def __init__(
|
def __init__(
|
||||||
cls, name: str, bases: tuple[type, ...], classdict: dict[str, Any]
|
cls, name: str, bases: tuple[type[object], ...], classdict: dict[str, Any]
|
||||||
) -> None:
|
) -> None:
|
||||||
converter_cls = cast(type["CConverter"], cls)
|
converter_cls = cast(type["CConverter"], cls)
|
||||||
add_c_converter(converter_cls)
|
add_c_converter(converter_cls)
|
||||||
|
@ -3217,7 +3217,7 @@ class CConverter(metaclass=CConverterAutoRegister):
|
||||||
|
|
||||||
# If not None, default must be isinstance() of this type.
|
# If not None, default must be isinstance() of this type.
|
||||||
# (You can also specify a tuple of types.)
|
# (You can also specify a tuple of types.)
|
||||||
default_type: bltns.type[Any] | tuple[bltns.type[Any], ...] | None = None
|
default_type: bltns.type[object] | tuple[bltns.type[object], ...] | None = None
|
||||||
|
|
||||||
# "default" converted into a C value, as a string.
|
# "default" converted into a C value, as a string.
|
||||||
# Or None if there is no default.
|
# Or None if there is no default.
|
||||||
|
@ -3683,7 +3683,7 @@ legacy_converters: ConverterDict = {}
|
||||||
ReturnConverterDict = dict[str, ReturnConverterType]
|
ReturnConverterDict = dict[str, ReturnConverterType]
|
||||||
return_converters: ReturnConverterDict = {}
|
return_converters: ReturnConverterDict = {}
|
||||||
|
|
||||||
TypeSet = set[bltns.type[Any]]
|
TypeSet = set[bltns.type[object]]
|
||||||
|
|
||||||
|
|
||||||
class bool_converter(CConverter):
|
class bool_converter(CConverter):
|
||||||
|
@ -4347,7 +4347,7 @@ class buffer: pass
|
||||||
class rwbuffer: pass
|
class rwbuffer: pass
|
||||||
class robuffer: pass
|
class robuffer: pass
|
||||||
|
|
||||||
StrConverterKeyType = tuple[frozenset[type], bool, bool]
|
StrConverterKeyType = tuple[frozenset[type[object]], bool, bool]
|
||||||
|
|
||||||
def str_converter_key(
|
def str_converter_key(
|
||||||
types: TypeSet, encoding: bool | str | None, zeroes: bool
|
types: TypeSet, encoding: bool | str | None, zeroes: bool
|
||||||
|
@ -4846,7 +4846,7 @@ class CReturnConverterAutoRegister(type):
|
||||||
def __init__(
|
def __init__(
|
||||||
cls: ReturnConverterType,
|
cls: ReturnConverterType,
|
||||||
name: str,
|
name: str,
|
||||||
bases: tuple[type, ...],
|
bases: tuple[type[object], ...],
|
||||||
classdict: dict[str, Any]
|
classdict: dict[str, Any]
|
||||||
) -> None:
|
) -> None:
|
||||||
add_c_return_converter(cls)
|
add_c_return_converter(cls)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue