Format: application/octet-stream
⬇ Download File (1.2 KB)
   1  import sys
   2  from typing import Any, Callable, Generic, Optional, TypeVar, overload
   3  
   4  if sys.version_info >= (3, 9):
   5      from types import GenericAlias
   6  
   7  _C = TypeVar("_C", bound=Callable[..., Any])
   8  _T = TypeVar("_T")
   9  
  10  class CallableProxyType(object):  # "weakcallableproxy"
  11      def __getattr__(self, attr: str) -> Any: ...
  12  
  13  class ProxyType(object):  # "weakproxy"
  14      def __getattr__(self, attr: str) -> Any: ...
  15  
  16  class ReferenceType(Generic[_T]):
  17      if sys.version_info >= (3, 4):
  18          __callback__: Callable[[ReferenceType[_T]], Any]
  19      def __init__(self, o: _T, callback: Optional[Callable[[ReferenceType[_T]], Any]] = ...) -> None: ...
  20      def __call__(self) -> Optional[_T]: ...
  21      def __hash__(self) -> int: ...
  22      if sys.version_info >= (3, 9):
  23          def __class_getitem__(cls, item: Any) -> GenericAlias: ...
  24  
  25  ref = ReferenceType
  26  
  27  def getweakrefcount(__object: Any) -> int: ...
  28  def getweakrefs(object: Any) -> int: ...
  29  @overload
  30  def proxy(object: _C, callback: Optional[Callable[[_C], Any]] = ...) -> CallableProxyType: ...
  31  
  32  # Return CallableProxyType if object is callable, ProxyType otherwise
  33  @overload
  34  def proxy(object: _T, callback: Optional[Callable[[_T], Any]] = ...) -> Any: ...
  35