File: weakref.pyi

package info (click to toggle)
mypy 0.470-complete-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,864 kB
  • ctags: 3,264
  • sloc: python: 21,838; makefile: 18
file content (47 lines) | stat: -rw-r--r-- 1,711 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Stubs for weakref (Python 2)
#
# Based on stub automatically generated by stubgen.

from typing import Any, MutableMapping, Generic, Iterator, List, TypeVar
from _weakref import (getweakrefcount, getweakrefs, ref, proxy,
                      CallableProxyType, ProxyType, ReferenceType)
from _weakrefset import WeakSet

ProxyTypes = ...  # type: Any

_KT = TypeVar('_KT')
_VT = TypeVar('_VT')

# Don't inherit from typing.Dict since
# isinstance(weakref.WeakValueDictionary(), dict) is False
class WeakValueDictionary(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
    def itervaluerefs(self) -> Iterator[ReferenceType[_VT]]: ...
    def valuerefs(self) -> List[ReferenceType[_VT]]: ...

    def __setitem__(self, k: _KT, v: _VT) -> None: ...
    def __delitem__(self, v: _KT) -> None: ...
    def __getitem__(self, k: _KT) -> _VT: ...
    def __len__(self) -> int: ...
    def __iter__(self) -> Iterator[_KT]: ...

    def has_key(self, key: _KT) -> bool: ...
    def copy(self) -> WeakValueDictionary[_KT, _VT]: ...

class WeakKeyDictionary(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
    def iterkeyrefs(self) -> Iterator[ReferenceType[_KT]]: ...
    def keyrefs(self) -> List[ReferenceType[_KT]]: ...

    def __setitem__(self, k: _KT, v: _VT) -> None: ...
    def __delitem__(self, v: _KT) -> None: ...
    def __getitem__(self, k: _KT) -> _VT: ...
    def __len__(self) -> int: ...
    def __iter__(self) -> Iterator[_KT]: ...

    def has_key(self, key: _KT) -> bool: ...
    def copy(self) -> WeakKeyDictionary[_KT, _VT]: ...

# TODO: make generic
class KeyedRef(ReferenceType):
    key = ...  # type: Any
    def __new__(type, ob, callback, key): ...
    def __init__(self, ob, callback, key): ...