1- from typing import Any , Dict , List , Optional
1+ import typing
22
33import cachelib
44
1111class PhpBB3 :
1212 def __init__ (
1313 self ,
14- app : Optional [flask .Flask ] = None ,
15- cache : Optional [cachelib .BaseCache ] = None ,
14+ app : typing . Optional [flask .Flask ] = None ,
15+ cache : typing . Optional [cachelib .BaseCache ] = None ,
1616 ) -> None :
1717 self .app = app
1818 if app is not None :
@@ -21,7 +21,7 @@ def __init__(
2121 def init_app (
2222 self ,
2323 app : flask .Flask ,
24- cache : Optional [cachelib .BaseCache ] = None
24+ cache : typing . Optional [cachelib .BaseCache ] = None
2525 ) -> None :
2626 self ._ensure_default_config (app )
2727
@@ -85,7 +85,7 @@ def _ensure_default_config(cls, app: flask.Flask) -> None:
8585 def _create_backend (
8686 cls ,
8787 backend_type : str ,
88- config : Dict [str , Any ],
88+ config : typing . Dict [str , typing . Any ],
8989 cache : cachelib .BaseCache
9090 ) -> flask_phpbb3 .backends .base .BaseBackend :
9191 if backend_type == 'psycopg2' :
@@ -102,7 +102,7 @@ def _backend(self) -> flask_phpbb3.backends.base.BaseBackend:
102102 """Returns phpbb3 backend"""
103103 current_app = self .app or flask .current_app
104104
105- backend : Optional [flask_phpbb3 .backends .base .BaseBackend ] = \
105+ backend : typing . Optional [flask_phpbb3 .backends .base .BaseBackend ] = \
106106 flask .g .get ('phpbb3_backend' , None )
107107
108108 if backend is None or backend .is_closed :
@@ -124,9 +124,9 @@ def get_autologin(
124124 self ,
125125 key : str ,
126126 cache : bool = False ,
127- cache_ttl : Optional [int ] = None
128- ) -> Optional [Dict ]:
129- output : Optional [Dict ] = self ._backend .execute (
127+ cache_ttl : typing . Optional [int ] = None
128+ ) -> typing . Optional [typing . Dict ]:
129+ output : typing . Optional [typing . Dict ] = self ._backend .execute (
130130 'get_autologin' ,
131131 key = key ,
132132 cache = cache ,
@@ -138,9 +138,9 @@ def get_session(
138138 self ,
139139 session_id : str ,
140140 cache : bool = False ,
141- cache_ttl : Optional [int ] = None
142- ) -> Optional [Dict ]:
143- output : Optional [Dict ] = self ._backend .execute (
141+ cache_ttl : typing . Optional [int ] = None
142+ ) -> typing . Optional [typing . Dict ]:
143+ output : typing . Optional [typing . Dict ] = self ._backend .execute (
144144 'get_session' ,
145145 session_id = session_id ,
146146 cache = cache ,
@@ -152,9 +152,9 @@ def get_user(
152152 self ,
153153 user_id : int ,
154154 cache : bool = False ,
155- cache_ttl : Optional [int ] = None
156- ) -> Optional [Dict ]:
157- output : Optional [Dict ] = self ._backend .execute (
155+ cache_ttl : typing . Optional [int ] = None
156+ ) -> typing . Optional [typing . Dict ]:
157+ output : typing . Optional [typing . Dict ] = self ._backend .execute (
158158 'get_user' ,
159159 user_id = user_id ,
160160 cache = cache ,
@@ -166,9 +166,9 @@ def get_user_profile(
166166 self ,
167167 user_id : int ,
168168 cache : bool = False ,
169- cache_ttl : Optional [int ] = None
170- ) -> Optional [Dict ]:
171- output : Optional [Dict ] = self ._backend .execute (
169+ cache_ttl : typing . Optional [int ] = None
170+ ) -> typing . Optional [typing . Dict ]:
171+ output : typing . Optional [typing . Dict ] = self ._backend .execute (
172172 'get_user_profile' ,
173173 user_id = user_id ,
174174 cache = cache ,
@@ -181,9 +181,9 @@ def has_membership(
181181 user_id : int ,
182182 group_id : int ,
183183 cache : bool = False ,
184- cache_ttl : Optional [int ] = None ,
185- ) -> Optional [bool ]:
186- output : Optional [bool ] = self ._backend .execute (
184+ cache_ttl : typing . Optional [int ] = None ,
185+ ) -> typing . Optional [bool ]:
186+ output : typing . Optional [bool ] = self ._backend .execute (
187187 'has_membership' ,
188188 user_id = user_id ,
189189 group_id = group_id ,
@@ -197,9 +197,9 @@ def has_membership_resolve(
197197 user_id : int ,
198198 group_name : str ,
199199 cache : bool = False ,
200- cache_ttl : Optional [int ] = None ,
201- ) -> Optional [bool ]:
202- output : Optional [bool ] = self ._backend .execute (
200+ cache_ttl : typing . Optional [int ] = None ,
201+ ) -> typing . Optional [bool ]:
202+ output : typing . Optional [bool ] = self ._backend .execute (
203203 'has_membership_resolve' ,
204204 user_id = user_id ,
205205 group_name = group_name ,
@@ -211,26 +211,27 @@ def has_membership_resolve(
211211 def fetch_acl_options (
212212 self ,
213213 skip : int = 0 ,
214- limit : Optional [int ] = 10 ,
214+ limit : typing . Optional [int ] = 10 ,
215215 cache : bool = False ,
216- cache_ttl : Optional [int ] = None ,
217- ) -> Optional [List [Dict ]]:
218- output : Optional [List [Dict ]] = self ._backend .execute (
219- 'fetch_acl_options' ,
220- skip = skip ,
221- limit = limit ,
222- cache = cache ,
223- cache_ttl = cache_ttl ,
224- )
216+ cache_ttl : typing .Optional [int ] = None ,
217+ ) -> typing .Optional [typing .List [typing .Dict ]]:
218+ output : typing .Optional [typing .List [typing .Dict ]] = \
219+ self ._backend .execute (
220+ 'fetch_acl_options' ,
221+ skip = skip ,
222+ limit = limit ,
223+ cache = cache ,
224+ cache_ttl = cache_ttl ,
225+ )
225226 return output
226227
227228 def get_unread_notifications_count (
228229 self ,
229230 user_id : int ,
230231 cache : bool = False ,
231- cache_ttl : Optional [int ] = None ,
232- ) -> Optional [Dict ]:
233- output : Optional [Dict ] = self ._backend .execute (
232+ cache_ttl : typing . Optional [int ] = None ,
233+ ) -> typing . Optional [typing . Dict ]:
234+ output : typing . Optional [typing . Dict ] = self ._backend .execute (
234235 'get_unread_notifications_count' ,
235236 user_id = user_id ,
236237 cache = cache ,
@@ -248,9 +249,9 @@ def execute_custom(
248249 self ,
249250 command : str ,
250251 cache : bool = False ,
251- cache_ttl : Optional [int ] = None ,
252- ** kwargs : Any
253- ) -> Any :
252+ cache_ttl : typing . Optional [int ] = None ,
253+ ** kwargs : typing . Any
254+ ) -> typing . Any :
254255 output = self ._backend .execute (
255256 command ,
256257 cache = cache ,
@@ -259,7 +260,7 @@ def execute_custom(
259260 )
260261 return output
261262
262- def teardown (self , exception : Any ) -> None :
263+ def teardown (self , exception : typing . Any ) -> None :
263264 backend : flask_phpbb3 .backends .base .BaseBackend = \
264265 flask .g .get ('phpbb3_backend' , None )
265266 if backend is not None :
0 commit comments