@@ -54,7 +54,7 @@ def __init__(
5454 self ._status_cgi_url = f"{ self .base_url } /status.cgi" # AirOS 8
5555 self ._stakick_cgi_url = f"{ self .base_url } /stakick.cgi" # AirOS 8
5656 self ._provmode_url = f"{ self .base_url } /api/provmode" # AirOS 8
57- self .current_csrf_token = None
57+ self .current_csrf_token : str | None = None
5858
5959 self ._use_json_for_login_post = False
6060
@@ -87,7 +87,7 @@ async def login(self) -> bool:
8787
8888 login_request_headers = {** self ._common_headers }
8989
90- post_data = None
90+ post_data : dict [ str , str ] | str | None = None
9191 if self ._use_json_for_login_post :
9292 login_request_headers ["Content-Type" ] = "application/json"
9393 post_data = json .dumps (login_payload )
@@ -114,7 +114,7 @@ async def login(self) -> bool:
114114 # If the AIROS_ cookie was parsed but isn't automatically added to the jar, add it manually
115115 if (
116116 morsel .key .startswith ("AIROS_" )
117- and morsel .key not in self .session .cookie_jar
117+ and morsel .key not in self .session .cookie_jar # type: ignore[operator]
118118 ):
119119 # `SimpleCookie`'s Morsel objects are designed to be compatible with cookie jars.
120120 # We need to set the domain if it's missing, otherwise the cookie might not be sent.
@@ -152,7 +152,7 @@ async def login(self) -> bool:
152152 if new_csrf_token :
153153 self .current_csrf_token = new_csrf_token
154154 else :
155- return
155+ return False
156156
157157 # Re-check cookies in self.session.cookie_jar AFTER potential manual injection
158158 airos_cookie_found = False
@@ -186,18 +186,16 @@ async def login(self) -> bool:
186186 log = f"Login failed with status { response .status } . Full Response: { response .text } "
187187 _LOGGER .error (log )
188188 raise AirOSConnectionAuthenticationError from None
189- except (TimeoutError , aiohttp .client_exceptions . ClientError ) as err :
189+ except (TimeoutError , aiohttp .ClientError ) as err :
190190 _LOGGER .exception ("Error during login" )
191191 raise AirOSDeviceConnectionError from err
192192 except asyncio .CancelledError :
193193 _LOGGER .info ("Login task was cancelled" )
194194 raise
195195
196- def derived_data (
197- self , response : dict [str , Any ] | None = None
198- ) -> dict [str , Any ] | None :
196+ def derived_data (self , response : dict [str , Any ] = {}) -> dict [str , Any ]:
199197 """Add derived data to the device response."""
200- derived = {
198+ derived : dict [ str , Any ] = {
201199 "station" : False ,
202200 "access_point" : False ,
203201 "ptp" : False ,
@@ -302,14 +300,14 @@ async def status(self) -> AirOSData:
302300 response_text ,
303301 )
304302 raise AirOSDeviceConnectionError
305- except (TimeoutError , aiohttp .client_exceptions . ClientError ) as err :
303+ except (TimeoutError , aiohttp .ClientError ) as err :
306304 _LOGGER .exception ("Status API call failed: %s" , err )
307305 raise AirOSDeviceConnectionError from err
308306 except asyncio .CancelledError :
309307 _LOGGER .info ("API status retrieval task was cancelled" )
310308 raise
311309
312- async def stakick (self , mac_address : str = None ) -> bool :
310+ async def stakick (self , mac_address : str | None = None ) -> bool :
313311 """Reconnect client station."""
314312 if not self .connected :
315313 _LOGGER .error ("Not connected, login first" )
@@ -340,7 +338,7 @@ async def stakick(self, mac_address: str = None) -> bool:
340338 log = f"Unable to restart connection response status { response .status } with { response_text } "
341339 _LOGGER .error (log )
342340 return False
343- except (TimeoutError , aiohttp .client_exceptions . ClientError ) as err :
341+ except (TimeoutError , aiohttp .ClientError ) as err :
344342 _LOGGER .exception ("Error during call to reconnect remote: %s" , err )
345343 raise AirOSDeviceConnectionError from err
346344 except asyncio .CancelledError :
@@ -379,7 +377,7 @@ async def provmode(self, active: bool = False) -> bool:
379377 log = f"Unable to change provisioning mode response status { response .status } with { response_text } "
380378 _LOGGER .error (log )
381379 return False
382- except (TimeoutError , aiohttp .client_exceptions . ClientError ) as err :
380+ except (TimeoutError , aiohttp .ClientError ) as err :
383381 _LOGGER .exception ("Error during call to change provisioning mode: %s" , err )
384382 raise AirOSDeviceConnectionError from err
385383 except asyncio .CancelledError :
0 commit comments