|
10 | 10 | from copy import deepcopy |
11 | 11 | from datetime import datetime |
12 | 12 | from threading import Condition, Lock |
13 | | -from typing import Optional, Dict, Mapping, Any |
| 13 | +from typing import Optional, Dict, Mapping, Any, Callable, Tuple |
| 14 | +from requests.adapters import Response |
14 | 15 |
|
15 | 16 | import requests |
16 | 17 |
|
@@ -247,8 +248,8 @@ def is_expired(self) -> bool: |
247 | 248 | def is_valid(self) -> bool: |
248 | 249 | return not self.is_expired() and self.last_seen is not None and self.last_parser is not None |
249 | 250 |
|
250 | | - def add_info(self) -> Mapping[str, Optional[Any]]: |
251 | | - info: Dict[str, Optional[Any]] = dict() |
| 251 | + def add_info(self) -> Dict[str, Any]: |
| 252 | + info: Dict[str, Any] = dict() |
252 | 253 | info['State'] = None |
253 | 254 | info['Resource'] = self.url |
254 | 255 | self._infos.append(info) |
@@ -319,7 +320,7 @@ def save_backup(self, data): |
319 | 320 | except IOError as ex: |
320 | 321 | log.warning("unable to save backup copy of {}: {}".format(self.url, ex)) |
321 | 322 |
|
322 | | - def load_resource(self, getter): |
| 323 | + def load_resource(self, getter: Callable[[str], Response]) -> Tuple[Optional[str], int, Dict[str, Any]]: |
323 | 324 | data: Optional[str] = None |
324 | 325 | status: int = 500 |
325 | 326 | info = self.add_info() |
|
0 commit comments