66import socket
77from contextlib import suppress
88from dataclasses import dataclass
9- from typing import TYPE_CHECKING , Any
9+ from typing import TYPE_CHECKING , Any , Self
1010
1111import aiohttp
1212import async_timeout
@@ -198,11 +198,11 @@ async def request(
198198 response .close ()
199199
200200 if content_type == "application/json" :
201- raise WLEDError ( # noqa: TRY301
201+ raise WLEDError (
202202 response .status ,
203203 json .loads (contents .decode ("utf8" )),
204204 )
205- raise WLEDError ( # noqa: TRY301
205+ raise WLEDError (
206206 response .status ,
207207 {"message" : contents .decode ("utf8" )},
208208 )
@@ -367,7 +367,7 @@ async def master(
367367
368368 await self .request ("/json/state" , method = "POST" , data = state )
369369
370- # pylint: disable=too-many-locals, too-many-branches
370+ # pylint: disable=too-many-locals, too-many-branches, too-many-arguments
371371 async def segment ( # noqa: PLR0912, PLR0913
372372 self ,
373373 segment_id : int ,
@@ -689,14 +689,15 @@ async def upgrade(self, *, version: str | AwesomeVersion) -> None:
689689 )
690690
691691 try :
692- async with async_timeout .timeout (self .request_timeout * 10 ):
693- async with self .session .get (
694- download_url ,
695- raise_for_status = True ,
696- ) as download :
697- form = aiohttp .FormData ()
698- form .add_field ("file" , await download .read (), filename = update_file )
699- await self .session .post (url , data = form )
692+ async with async_timeout .timeout (
693+ self .request_timeout * 10 ,
694+ ), self .session .get (
695+ download_url ,
696+ raise_for_status = True ,
697+ ) as download :
698+ form = aiohttp .FormData ()
699+ form .add_field ("file" , await download .read (), filename = update_file )
700+ await self .session .post (url , data = form )
700701 except asyncio .TimeoutError as exception :
701702 msg = "Timeout occurred while fetching WLED version information from GitHub"
702703 raise WLEDConnectionTimeoutError (msg ) from exception
@@ -804,7 +805,7 @@ async def close(self) -> None:
804805 if self .session and self ._close_session :
805806 await self .session .close ()
806807
807- async def __aenter__ (self ) -> WLED :
808+ async def __aenter__ (self ) -> Self :
808809 """Async enter.
809810
810811 Returns
@@ -813,7 +814,7 @@ async def __aenter__(self) -> WLED:
813814 """
814815 return self
815816
816- async def __aexit__ (self , * _exc_info : Any ) -> None :
817+ async def __aexit__ (self , * _exc_info : object ) -> None :
817818 """Async exit.
818819
819820 Args:
0 commit comments