fix typing

This commit is contained in:
Xavier Olive 2022-12-29 19:22:35 +01:00
parent a30565b4ef
commit ff19b54868
2 changed files with 15 additions and 11 deletions

View File

@ -2,7 +2,9 @@
Decoding Air-Air Surveillance (ACAS) DF=0/16 Decoding Air-Air Surveillance (ACAS) DF=0/16
""" """
from pyModeS import common from __future__ import annotations
from .. import common
import warnings import warnings
warnings.simplefilter("always", UserWarning) warnings.simplefilter("always", UserWarning)
@ -23,7 +25,7 @@ def isACAS(msg: str) -> bool:
return False return False
def rac(msg: str) -> str: def rac(msg: str) -> None | str:
"""Resolution Advisory Complement. """Resolution Advisory Complement.
:param msg: 28 hexdigits string :param msg: 28 hexdigits string
@ -52,7 +54,7 @@ def rac(msg: str) -> str:
return "; ".join(RAC) return "; ".join(RAC)
def rat(msg: str) -> bool: def rat(msg: str) -> None | int:
"""RA terminated indicator """RA terminated indicator
Mode S transponder is still required to report RA 18 seconds after Mode S transponder is still required to report RA 18 seconds after
@ -70,7 +72,7 @@ def rat(msg: str) -> bool:
return mte return mte
def mte(msg: str) -> bool: def mte(msg: str) -> None | int:
"""Multiple threat encounter. """Multiple threat encounter.
:param msg: 28 hexdigits string :param msg: 28 hexdigits string
@ -85,7 +87,7 @@ def mte(msg: str) -> bool:
return mte return mte
def ara(msg: str) -> str: def ara(msg: str) -> None | str:
"""Decode active resolution advisory. """Decode active resolution advisory.
:param msg: 28 bytes hexadecimal message string :param msg: 28 bytes hexadecimal message string

View File

@ -5,10 +5,10 @@
# (Subtype 1) # (Subtype 1)
# ------------------------------------------ # ------------------------------------------
from typing import Tuple from __future__ import annotations
from pyModeS import common
from pyModeS.decoder import acas from ... import common
from .. import acas
def threat_type(msg: str) -> int: def threat_type(msg: str) -> int:
@ -40,7 +40,7 @@ def threat_identity(msg: str) -> str:
raise RuntimeError("%s: Missing threat identity (ICAO)") raise RuntimeError("%s: Missing threat identity (ICAO)")
def threat_location(msg: str) -> Tuple: def threat_location(msg: str) -> None | tuple[int, int, int]:
"""Get the altitude, range, and bearing of the threat. """Get the altitude, range, and bearing of the threat.
Altitude is the Mode C altitude Altitude is the Mode C altitude
@ -58,6 +58,8 @@ def threat_location(msg: str) -> Tuple:
bearing = common.bin2int(mb[51:57]) bearing = common.bin2int(mb[51:57])
return altitude, distance, bearing return altitude, distance, bearing
return None
def has_multiple_threats(msg: str) -> bool: def has_multiple_threats(msg: str) -> bool:
"""Indicate if the ACAS is processing multiple threats simultaneously. """Indicate if the ACAS is processing multiple threats simultaneously.
@ -68,7 +70,7 @@ def has_multiple_threats(msg: str) -> bool:
return acas.mte(msg) == 1 return acas.mte(msg) == 1
def active_resolution_advisories(msg: str) -> str: def active_resolution_advisories(msg: str) -> None | str:
"""Decode active resolution advisory. """Decode active resolution advisory.
Uses ARA decoding function from ACAS module. Uses ARA decoding function from ACAS module.
@ -91,7 +93,7 @@ def is_ra_terminated(msg: str) -> bool:
return acas.rat(msg) == 1 return acas.rat(msg) == 1
def ra_complement(msg: str) -> str: def ra_complement(msg: str) -> None | str:
"""Resolution Advisory Complement. """Resolution Advisory Complement.
:param msg: 28 hexdigits string :param msg: 28 hexdigits string