Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -1,4 +1,4 @@
from typing import Callable, Generic, Iterator, Optional, TypeVar
from typing import Callable, Generic, Iterator, TypeVar
from .abc import DefaultMapping as DefaultMapping
@@ -6,7 +6,7 @@ _KT = TypeVar("_KT")
_VT = TypeVar("_VT")
class Cache(DefaultMapping[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> None: ...
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def __delitem__(self, key: _KT) -> None: ...

View File

@@ -1,13 +1,11 @@
from _typeshed import IdentityFunction
from typing import Any, Callable, ContextManager, MutableMapping, Optional, TypeVar
from typing import Any, Callable, ContextManager, MutableMapping, TypeVar
_KT = TypeVar("_KT")
def cached(
cache: Optional[MutableMapping[_KT, Any]], key: Callable[..., _KT] = ..., lock: Optional[ContextManager[Any]] = ...
cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ...
) -> IdentityFunction: ...
def cachedmethod(
cache: Callable[[Any], Optional[MutableMapping[_KT, Any]]],
key: Callable[..., _KT] = ...,
lock: Optional[ContextManager[Any]] = ...,
cache: Callable[[Any], MutableMapping[_KT, Any] | None], key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ...
) -> IdentityFunction: ...

View File

@@ -1,11 +1,9 @@
from _typeshed import IdentityFunction
from typing import Callable, Optional, Sequence, TypeVar
from typing import Callable, Sequence, TypeVar
_T = TypeVar("_T")
def lfu_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ...
def lru_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ...
def rr_cache(
maxsize: float = ..., choice: Optional[Callable[[Sequence[_T]], _T]] = ..., typed: bool = ...
) -> IdentityFunction: ...
def rr_cache(maxsize: float = ..., choice: Callable[[Sequence[_T]], _T] | None = ..., typed: bool = ...) -> IdentityFunction: ...
def ttl_cache(maxsize: float = ..., ttl: float = ..., timer: float = ..., typed: bool = ...) -> IdentityFunction: ...

View File

@@ -1,4 +1,4 @@
from typing import Callable, Iterator, Optional, TypeVar
from typing import Callable, Iterator, TypeVar
from .cache import Cache
@@ -6,7 +6,7 @@ _KT = TypeVar("_KT")
_VT = TypeVar("_VT")
class LFUCache(Cache[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> None: ...
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ...
def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Callable, Iterator, Optional, TypeVar
from typing import Callable, Iterator, TypeVar
from .cache import Cache as Cache
@@ -6,7 +6,7 @@ _KT = TypeVar("_KT")
_VT = TypeVar("_VT")
class LRUCache(Cache[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> None: ...
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ...
def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Callable, Iterator, Optional, Sequence, TypeVar
from typing import Callable, Iterator, Sequence, TypeVar
from .cache import Cache as Cache
@@ -7,10 +7,7 @@ _VT = TypeVar("_VT")
class RRCache(Cache[_KT, _VT]):
def __init__(
self,
maxsize: float,
choice: Optional[Callable[[Sequence[_KT]], _KT]] = ...,
getsizeof: Optional[Callable[[_VT], float]] = ...,
self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT] | None = ..., getsizeof: Callable[[_VT], float] | None = ...
) -> None: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...

View File

@@ -1,4 +1,4 @@
from typing import Callable, Iterator, Optional, TypeVar
from typing import Callable, Iterator, TypeVar
from .cache import Cache as Cache
@@ -7,7 +7,7 @@ _VT = TypeVar("_VT")
class TTLCache(Cache[_KT, _VT]):
def __init__(
self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Optional[Callable[[_VT], float]] = ...
self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Callable[[_VT], float] | None = ...
) -> None: ...
def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ...
@@ -20,4 +20,4 @@ class TTLCache(Cache[_KT, _VT]):
def timer(self) -> Callable[[], float]: ...
@property
def ttl(self) -> float: ...
def expire(self, time: Optional[float] = ...) -> None: ...
def expire(self, time: float | None = ...) -> None: ...