|
1 | 1 | """v2 ready: Common functions used by various internal modules""" |
2 | 2 | from types import FunctionType |
3 | | -from typing import Final, Any |
| 3 | +from typing import Final, Any, TYPE_CHECKING |
4 | 4 |
|
5 | 5 | from . import exceptions |
6 | 6 | from .requests import Requests as requests |
7 | 7 |
|
| 8 | +if TYPE_CHECKING: |
| 9 | + # Having to do this is quite inelegant, but this is commons.py, so this is done to avoid cyclic imports |
| 10 | + from ..site._base import BaseSiteComponent |
| 11 | + |
8 | 12 | headers: Final = { |
9 | 13 | "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " |
10 | 14 | "(KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36", |
|
60 | 64 | } |
61 | 65 |
|
62 | 66 |
|
63 | | -def api_iterative_data(fetch_func: 'FunctionType', limit: int, offset: int, max_req_limit: int = 40, |
| 67 | +def api_iterative_data(fetch_func: FunctionType, limit: int, offset: int, max_req_limit: int = 40, |
64 | 68 | unpack: bool = True): |
65 | 69 | """ |
66 | 70 | Iteratively gets data by calling fetch_func with a moving offset and a limit. |
@@ -123,7 +127,7 @@ def fetch(off: int, lim: int): |
123 | 127 | return api_data |
124 | 128 |
|
125 | 129 |
|
126 | | -def _get_object(identificator_name, identificator, Class, NotFoundException, session=None): |
| 130 | +def _get_object(identificator_name, identificator, Class, NotFoundException, session=None) -> 'BaseSiteComponent': |
127 | 131 | # Internal function: Generalization of the process ran by get_user, get_studio etc. |
128 | 132 | # Builds an object of class that is inheriting from BaseSiteComponent |
129 | 133 | # # Class must inherit from BaseSiteComponent |
|
0 commit comments