utils: Add more typing

This commit is contained in:
Teemu Ikonen
2023-06-07 22:18:55 +03:00
parent 7dae313cc4
commit 057dd67557

View File

@@ -187,7 +187,7 @@ def min_or_none(seq: list[Optional[int]]) -> Optional[int]:
return min(seq) # type: ignore return min(seq) # type: ignore
def opc_to_mcc_mnc(opc): def opc_to_mcc_mnc(opc: str) -> (Optional[int], Optional[int]):
"""Return (mcc, mnc) integer tuple from opc string.""" """Return (mcc, mnc) integer tuple from opc string."""
mcclen = 3 mcclen = 3
try: try:
@@ -200,7 +200,7 @@ def opc_to_mcc_mnc(opc):
return mcc, mnc return mcc, mnc
def mcc_mnc_to_opc(mcc, mnc): def mcc_mnc_to_opc(mcc: int, mnc: int) -> str:
"""Return operator code (OPC) string formed from MCC and MNC given as ints. """Return operator code (OPC) string formed from MCC and MNC given as ints.
MCC and MNC are actually strings, but Ichnaea API treats them as ints, MCC and MNC are actually strings, but Ichnaea API treats them as ints,
@@ -216,11 +216,13 @@ def mcc_mnc_to_opc(mcc, mnc):
return f'{mcc:03}{mnc:02}' return f'{mcc:03}{mnc:02}'
def encode_cellid(tec, opc, lac, cid, **kwargs): def encode_cellid(tec: str, opc: str, lac: int, cid: int, **kwargs) -> str:
return f'{tec.upper()}_{opc}_{lac}_{cid}' return f'{tec.upper()}_{opc}_{lac}_{cid}'
def encode_cellarea(tec, opc, lac, **kwargs):
def encode_cellarea(tec: str, opc: str, lac: int, **kwargs) -> str:
return f'c_{tec.upper()}_{opc}_{lac}' return f'c_{tec.upper()}_{opc}_{lac}'
def encode_wifi(mac):
def encode_wifi(mac: str) -> str:
return f'w_{mac.lower()}' return f'w_{mac.lower()}'