11"""Connection to the ISY."""
22
3+ from __future__ import annotations
4+
35import asyncio
46import ssl
57from urllib .parse import quote , urlencode
@@ -57,15 +59,15 @@ class Connection:
5759
5860 def __init__ (
5961 self ,
60- address ,
61- port ,
62- username ,
63- password ,
64- use_https = False ,
65- tls_ver = 1.1 ,
66- webroot = "" ,
67- websession = None ,
68- ):
62+ address : str ,
63+ port : int ,
64+ username : str ,
65+ password : str ,
66+ use_https : bool = False ,
67+ tls_ver : float = 1.1 ,
68+ webroot : str = "" ,
69+ websession : aiohttp . ClientSession | None = None ,
70+ ) -> None :
6971 """Initialize the Connection object."""
7072 if len (_LOGGER .handlers ) == 0 :
7173 enable_logging (add_null_handler = True )
@@ -90,27 +92,27 @@ def __init__(
9092 self .req_session = websession
9193 self .sslcontext = get_sslcontext (use_https , tls_ver )
9294
93- async def test_connection (self ):
95+ async def test_connection (self ) -> str | None :
9496 """Test the connection and get the config for the ISY."""
9597 config = await self .get_config (retries = None )
9698 if not config :
9799 _LOGGER .error ("Could not connect to the ISY with the parameters provided." )
98100 raise ISYConnectionError
99101 return config
100102
101- def increase_available_connections (self ):
103+ def increase_available_connections (self ) -> None :
102104 """Increase the number of allowed connections for newer hardware."""
103105 _LOGGER .debug ("Increasing available simultaneous connections" )
104106 self .semaphore = asyncio .Semaphore (
105107 MAX_HTTPS_CONNECTIONS_IOX if self .use_https else MAX_HTTP_CONNECTIONS_IOX
106108 )
107109
108- async def close (self ):
110+ async def close (self ) -> None :
109111 """Cleanup connections and prepare for exit."""
110112 await self .req_session .close ()
111113
112114 @property
113- def connection_info (self ):
115+ def connection_info (self ) -> dict [ str , str | int | bytes | None ] :
114116 """Return the connection info required to connect to the ISY."""
115117 connection_info = {}
116118 connection_info ["auth" ] = self ._auth .encode ()
@@ -124,12 +126,12 @@ def connection_info(self):
124126 return connection_info
125127
126128 @property
127- def url (self ):
129+ def url (self ) -> str :
128130 """Return the full connection url."""
129131 return self ._url
130132
131133 # COMMON UTILITIES
132- def compile_url (self , path : list [str ], query : str | None = None ):
134+ def compile_url (self , path : list [str ], query : str | None = None ) -> str :
133135 """Compile the URL to fetch from the ISY."""
134136 url = self .url
135137 if path is not None :
0 commit comments