mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 02:41:16 +08:00
Add missing function attributes to builtins.function (#6804)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -23,7 +23,7 @@ from _typeshed import (
|
||||
SupportsWrite,
|
||||
)
|
||||
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
|
||||
from types import CodeType, TracebackType
|
||||
from types import CodeType, TracebackType, _Cell
|
||||
from typing import (
|
||||
IO,
|
||||
AbstractSet,
|
||||
@@ -764,13 +764,22 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
|
||||
if sys.version_info >= (3, 9):
|
||||
def __class_getitem__(cls, __item: Any) -> GenericAlias: ...
|
||||
|
||||
# Make sure this class definition stays roughly in line with `types.FunctionType`
|
||||
@final
|
||||
class function:
|
||||
# TODO not defined in builtins!
|
||||
__name__: str
|
||||
__module__: str
|
||||
__closure__: tuple[_Cell, ...] | None
|
||||
__code__: CodeType
|
||||
__defaults__: tuple[Any, ...] | None
|
||||
__dict__: dict[str, Any]
|
||||
__globals__: dict[str, Any]
|
||||
__name__: str
|
||||
__qualname__: str
|
||||
__annotations__: dict[str, Any]
|
||||
__kwdefaults__: dict[str, Any]
|
||||
__module__: str
|
||||
# mypy uses `builtins.function.__get__` to represent methods, properties, and getset_descriptors so we type the return as Any.
|
||||
def __get__(self, obj: object | None, type: type | None = ...) -> Any: ...
|
||||
|
||||
class list(MutableSequence[_T], Generic[_T]):
|
||||
@overload
|
||||
|
||||
@@ -39,6 +39,7 @@ class _Cell:
|
||||
__hash__: None # type: ignore[assignment]
|
||||
cell_contents: Any
|
||||
|
||||
# Make sure this class definition stays roughly in line with `builtins.function`
|
||||
@final
|
||||
class FunctionType:
|
||||
__closure__: tuple[_Cell, ...] | None
|
||||
@@ -59,7 +60,7 @@ class FunctionType:
|
||||
closure: tuple[_Cell, ...] | None = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
|
||||
def __get__(self, obj: object | None, type: type | None) -> MethodType: ...
|
||||
def __get__(self, obj: object | None, type: type | None = ...) -> MethodType: ...
|
||||
|
||||
LambdaType = FunctionType
|
||||
|
||||
|
||||
@@ -270,6 +270,9 @@ pydoc.Helper.symbols_ # Loop variable in class https://github.com/python/typesh
|
||||
pydoc.Helper.topic # Loop variable in class https://github.com/python/typeshed/issues/6401#issuecomment-981178522
|
||||
# Dynamically specified by __getattr__, and thus don't exist on the class
|
||||
tempfile._TemporaryFileWrapper.[\w_]+
|
||||
# stubtest incorrectly highlights the type argument as not having a default value.
|
||||
types.FunctionType.__get__
|
||||
types.LambdaType.__get__
|
||||
# Various classes in typing aren't types at runtime. In addition, mypy thinks some special forms are tautologically defined.
|
||||
typing.[A-Z]\w+
|
||||
typing_extensions\..*
|
||||
|
||||
Reference in New Issue
Block a user