mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Reverts https://github.com/python/typeshed/pull/8465 Fixes https://github.com/python/typeshed/issues/10424 Closes https://github.com/python/typeshed/pull/10425 https://github.com/python/typeshed/pull/8465 caused regressions: see https://github.com/python/typeshed/issues/10424 and https://github.com/python/mypy/issues/13800. Since it didn't fix any known problems (just some stylistic nits that we had), let's just revert the PR.
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import sys
|
|
from collections.abc import Callable
|
|
from typing import Any, Generic, TypeVar, overload
|
|
from typing_extensions import Self, final
|
|
|
|
if sys.version_info >= (3, 9):
|
|
from types import GenericAlias
|
|
|
|
_C = TypeVar("_C", bound=Callable[..., Any])
|
|
_T = TypeVar("_T")
|
|
|
|
@final
|
|
class CallableProxyType(Generic[_C]): # "weakcallableproxy"
|
|
def __getattr__(self, attr: str) -> Any: ...
|
|
__call__: _C
|
|
|
|
@final
|
|
class ProxyType(Generic[_T]): # "weakproxy"
|
|
def __getattr__(self, attr: str) -> Any: ...
|
|
|
|
class ReferenceType(Generic[_T]):
|
|
__callback__: Callable[[ReferenceType[_T]], Any]
|
|
def __new__(cls, __o: _T, __callback: Callable[[ReferenceType[_T]], Any] | None = ...) -> Self: ...
|
|
def __call__(self) -> _T | None: ...
|
|
def __hash__(self) -> int: ...
|
|
if sys.version_info >= (3, 9):
|
|
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
|
|
|
|
ref = ReferenceType
|
|
|
|
def getweakrefcount(__object: Any) -> int: ...
|
|
def getweakrefs(__object: Any) -> list[Any]: ...
|
|
|
|
# Return CallableProxyType if object is callable, ProxyType otherwise
|
|
@overload
|
|
def proxy(__object: _C, __callback: Callable[[_C], Any] | None = None) -> CallableProxyType[_C]: ...
|
|
@overload
|
|
def proxy(__object: _T, __callback: Callable[[_T], Any] | None = None) -> Any: ...
|