diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index d8956df6b327..a0656531a180 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -234,6 +234,7 @@ asyncio.locks.Condition.acquire asyncio.locks.Condition.locked asyncio.locks.Condition.release +builtins.function # stubtest believes this exists in the stubs when it doesn't builtins.memoryview.__contains__ # C type that implements __getitem__ builtins.reveal_locals # Builtins that type checkers pretends exist builtins.reveal_type # Builtins that type checkers pretends exist diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 416d793de61c..b4dc2b5fb7e7 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1065,57 +1065,6 @@ class tuple(Sequence[_T_co]): def index(self, value: Any, start: SupportsIndex = 0, stop: SupportsIndex = sys.maxsize, /) -> int: ... def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... -# Doesn't exist at runtime, but deleting this breaks mypy and pyright. See: -# https://github.com/python/typeshed/issues/7580 -# https://github.com/python/mypy/issues/8240 -# Obsolete, use types.FunctionType instead. -@final -@type_check_only -class function: - # Make sure this class definition stays roughly in line with `types.FunctionType` - @property - def __closure__(self) -> tuple[CellType, ...] | None: ... - __code__: CodeType - __defaults__: tuple[Any, ...] | None - __dict__: dict[str, Any] - @property - def __globals__(self) -> dict[str, Any]: ... - __name__: str - __qualname__: str - __annotations__: dict[str, AnnotationForm] - if sys.version_info >= (3, 14): - __annotate__: AnnotateFunc | None - __kwdefaults__: dict[str, Any] | None - if sys.version_info >= (3, 10): - @property - def __builtins__(self) -> dict[str, Any]: ... - if sys.version_info >= (3, 12): - __type_params__: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] - - __module__: str - if sys.version_info >= (3, 13): - def __new__( - cls, - code: CodeType, - globals: dict[str, Any], - name: str | None = None, - argdefs: tuple[object, ...] | None = None, - closure: tuple[CellType, ...] | None = None, - kwdefaults: dict[str, object] | None = None, - ) -> Self: ... - else: - def __new__( - cls, - code: CodeType, - globals: dict[str, Any], - name: str | None = None, - argdefs: tuple[object, ...] | None = None, - closure: tuple[CellType, ...] | None = None, - ) -> Self: ... - - # mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any. - def __get__(self, instance: object, owner: type | None = None, /) -> Any: ... - @disjoint_base class list(MutableSequence[_T]): @overload diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 568f6ea68d0b..eaff14aeac06 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -68,7 +68,6 @@ _T2 = TypeVar("_T2") _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) -# Make sure this class definition stays roughly in line with `builtins.function` @final class FunctionType: @property