Skip to content

Commit 120e991

Browse files
authored
update CacheControl stubs via psf/cachecontrol#279 (#599)
1 parent 581c557 commit 120e991

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

mypy-stubs/cachecontrol/cache.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class BaseCache:
2-
def get(self, key: str) -> str | None: ...
3-
def set(self, key: str, value: str) -> None: ...
2+
def get(self, key: str) -> bytes | None: ...
3+
def set(self, key: str, value: bytes, expires: int | None = None) -> None: ...
44
def delete(self, key: str) -> None: ...
55
def close(self) -> None: ...

mypy-stubs/cachecontrol/caches/file_cache.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ class _LockClass:
1010
_lock_class = ContextManager[_LockClass]
1111

1212
class FileCache(BaseCache):
13-
directory: str | PathLike[str]
13+
directory: str
1414
forever: bool
15-
filemode: str
16-
dirmode: str
17-
lock_class: _lock_class
15+
filemode: int
16+
dirmode: int
17+
lock_class: _lock_class | None = None
1818
def __init__(
1919
self,
2020
directory: str | PathLike[str],
@@ -26,6 +26,6 @@ class FileCache(BaseCache):
2626
) -> None: ...
2727
@staticmethod
2828
def encode(x: str) -> str: ...
29-
def get(self, key: str) -> None | str: ...
30-
def set(self, key: str, value: str) -> None: ...
29+
def get(self, key: str) -> None | bytes: ...
30+
def set(self, key: str, value: bytes, expires: int | None = None) -> None: ...
3131
def delete(self, key: str) -> None: ...
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
from typing import Collection
2+
13
from _typeshed import Incomplete
24

3-
logger: Incomplete
4-
URI: Incomplete
5+
from .cache import BaseCache
56

67
class CacheController:
7-
cache: Incomplete
8-
cache_etags: Incomplete
8+
cache: BaseCache
9+
cache_etags: bool
910
serializer: Incomplete
10-
cacheable_status_codes: Incomplete
11+
cacheable_status_codes: Collection[int] | None = None
1112
def __init__(
1213
self,
13-
cache: Incomplete | None = ...,
14-
cache_etags: bool = ...,
15-
serializer: Incomplete | None = ...,
16-
status_codes: Incomplete | None = ...,
14+
cache: BaseCache | None = None,
15+
cache_etags: bool = True,
16+
serializer: Incomplete | None = None,
17+
status_codes: Collection[int] | None = None,
1718
) -> None: ...

mypy-stubs/cachecontrol/wrapper.pyi

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
from typing import Collection, Type
2+
13
from _typeshed import Incomplete
24
from requests import Session
35

6+
from .cache import BaseCache
7+
from .controller import CacheController
8+
49
def CacheControl(
510
sess: Session,
6-
cache: Incomplete | None = ...,
7-
cache_etags: bool = ...,
8-
serializer: Incomplete | None = ...,
9-
heuristic: Incomplete | None = ...,
10-
controller_class: Incomplete | None = ...,
11-
adapter_class: Incomplete | None = ...,
12-
cacheable_methods: Incomplete | None = ...,
11+
cache: BaseCache | None = None,
12+
cache_etags: bool = True,
13+
serializer: Incomplete | None = None,
14+
heuristic: Incomplete | None = None,
15+
controller_class: Type[CacheController] | None = None,
16+
adapter_class: Incomplete | None = None,
17+
cacheable_methods: Collection[str] | None = None,
1318
) -> Session: ...

0 commit comments

Comments
 (0)