From ff19b54868d092a85798347ccb1cfd9c5fca4872 Mon Sep 17 00:00:00 2001 From: Xavier Olive Date: Thu, 29 Dec 2022 19:22:35 +0100 Subject: [PATCH] fix typing --- pyModeS/decoder/acas.py | 12 +++++++----- pyModeS/decoder/bds/bds61_st2.py | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pyModeS/decoder/acas.py b/pyModeS/decoder/acas.py index 47a2dd8..ace13bd 100644 --- a/pyModeS/decoder/acas.py +++ b/pyModeS/decoder/acas.py @@ -2,7 +2,9 @@ Decoding Air-Air Surveillance (ACAS) DF=0/16 """ -from pyModeS import common +from __future__ import annotations + +from .. import common import warnings warnings.simplefilter("always", UserWarning) @@ -23,7 +25,7 @@ def isACAS(msg: str) -> bool: return False -def rac(msg: str) -> str: +def rac(msg: str) -> None | str: """Resolution Advisory Complement. :param msg: 28 hexdigits string @@ -52,7 +54,7 @@ def rac(msg: str) -> str: return "; ".join(RAC) -def rat(msg: str) -> bool: +def rat(msg: str) -> None | int: """RA terminated indicator Mode S transponder is still required to report RA 18 seconds after @@ -70,7 +72,7 @@ def rat(msg: str) -> bool: return mte -def mte(msg: str) -> bool: +def mte(msg: str) -> None | int: """Multiple threat encounter. :param msg: 28 hexdigits string @@ -85,7 +87,7 @@ def mte(msg: str) -> bool: return mte -def ara(msg: str) -> str: +def ara(msg: str) -> None | str: """Decode active resolution advisory. :param msg: 28 bytes hexadecimal message string diff --git a/pyModeS/decoder/bds/bds61_st2.py b/pyModeS/decoder/bds/bds61_st2.py index 2726873..90bc061 100644 --- a/pyModeS/decoder/bds/bds61_st2.py +++ b/pyModeS/decoder/bds/bds61_st2.py @@ -5,10 +5,10 @@ # (Subtype 1) # ------------------------------------------ -from typing import Tuple -from pyModeS import common +from __future__ import annotations -from pyModeS.decoder import acas +from ... import common +from .. import acas def threat_type(msg: str) -> int: @@ -40,7 +40,7 @@ def threat_identity(msg: str) -> str: 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. Altitude is the Mode C altitude @@ -58,6 +58,8 @@ def threat_location(msg: str) -> Tuple: bearing = common.bin2int(mb[51:57]) return altitude, distance, bearing + return None + def has_multiple_threats(msg: str) -> bool: """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 -def active_resolution_advisories(msg: str) -> str: +def active_resolution_advisories(msg: str) -> None | str: """Decode active resolution advisory. Uses ARA decoding function from ACAS module. @@ -91,7 +93,7 @@ def is_ra_terminated(msg: str) -> bool: return acas.rat(msg) == 1 -def ra_complement(msg: str) -> str: +def ra_complement(msg: str) -> None | str: """Resolution Advisory Complement. :param msg: 28 hexdigits string