Skip to content

Commit

Permalink
added typehints
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Perschon <[email protected]>
  • Loading branch information
tofuSCHNITZEL committed Dec 24, 2023
1 parent 90ffad2 commit 8f14722
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions unifi_ap/unifi_ap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Communicate with an UniFi accesspoint"""
import json
import paramiko

from typing import Any

class UniFiAPConnectionException(Exception):
"""Exception indicating problems with the connection to the accespoint"""
Expand All @@ -24,8 +24,8 @@ def __init__(
self,
target: str,
username: str,
password: str = None,
key_file: str = None,
password: str | None = None,
key_file: str | None = None,
port: int = 22,
timeout: int = 30,
) -> None:
Expand Down Expand Up @@ -67,18 +67,18 @@ def _fetch_ap_data(self) -> dict:
def get_ssids(self) -> set | None:
"""Returns all SSIDs from the accesspoint"""
ap_data = self._fetch_ap_data()
ssids = set()
ssids: set[str] = set()
if self.unifi_ssid_array not in ap_data:
return None
for vap in ap_data[self.unifi_ssid_array]:
ssids.add(vap.get("essid"))

return ssids

def get_clients(self, for_ssids: list = None) -> dict | None:
def get_clients(self, for_ssids: list | None = None) -> dict | None:
"""Returns all clients from the accesspoint connected to any or certain SSIDs"""
ap_data = self._fetch_ap_data()
clients = {}
clients: dict[str, dict[str, Any]] = {}

if self.unifi_ssid_array not in ap_data:
return None
Expand Down

0 comments on commit 8f14722

Please sign in to comment.