diff options
| author | Jordan Cook <jordan.cook.git@proton.me> | 2022-12-11 22:28:55 -0600 |
|---|---|---|
| committer | Jordan Cook <jordan.cook.git@proton.me> | 2022-12-13 16:27:49 -0600 |
| commit | f7281895698f33b9c41239b5be3a961fd1691b99 (patch) | |
| tree | 233d6439c5f5a9b770a4206aed8fbe26e60d3a94 /requests_cache/serializers | |
| parent | ca26b146592e08ff237cf9b6cccdba56eb2af484 (diff) | |
| download | requests-cache-f7281895698f33b9c41239b5be3a961fd1691b99.tar.gz | |
Update type hints to appease Pylance and stricter mypy settings
Diffstat (limited to 'requests_cache/serializers')
| -rw-r--r-- | requests_cache/serializers/cattrs.py | 9 | ||||
| -rw-r--r-- | requests_cache/serializers/pipeline.py | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/requests_cache/serializers/cattrs.py b/requests_cache/serializers/cattrs.py index 13d05e6..bf45c2d 100644 --- a/requests_cache/serializers/cattrs.py +++ b/requests_cache/serializers/cattrs.py @@ -14,7 +14,7 @@ serialization formats. from datetime import datetime, timedelta from decimal import Decimal from json import JSONDecodeError -from typing import Callable, Dict, ForwardRef, MutableMapping +from typing import Callable, Dict, ForwardRef, MutableMapping, Optional from cattr import Converter from requests.cookies import RequestsCookieJar, cookiejar_from_dict @@ -50,7 +50,10 @@ class CattrStage(Stage): """ def __init__( - self, factory: Callable[..., Converter] = None, decode_content: bool = False, **kwargs + self, + factory: Optional[Callable[..., Converter]] = None, + decode_content: bool = False, + **kwargs ): self.converter = init_converter(factory, **kwargs) self.decode_content = decode_content @@ -68,7 +71,7 @@ class CattrStage(Stage): def init_converter( - factory: Callable[..., Converter] = None, + factory: Optional[Callable[..., Converter]] = None, convert_datetime: bool = True, convert_timedelta: bool = True, ) -> Converter: diff --git a/requests_cache/serializers/pipeline.py b/requests_cache/serializers/pipeline.py index 652c8f5..320e498 100644 --- a/requests_cache/serializers/pipeline.py +++ b/requests_cache/serializers/pipeline.py @@ -4,7 +4,7 @@ :classes-only: :nosignatures: """ -from typing import Any, Callable, Sequence, Union +from typing import Any, Callable, Optional, Sequence, Union from ..models import CachedResponse @@ -43,7 +43,7 @@ class SerializerPipeline: is_binary: Indicates whether the serialized content is binary """ - def __init__(self, stages: Sequence, name: str = None, is_binary: bool = False): + def __init__(self, stages: Sequence, name: Optional[str] = None, is_binary: bool = False): self.is_binary = is_binary self.stages = stages self.dump_stages = [stage.dumps for stage in stages] |
