22
33from logging import Logger
44from time import monotonic
5- from typing import Any
5+ from typing import Any , cast
66
77from flockwave .gps .vectors import FlatEarthToGPSCoordinateTransformation
88
99from flockwave .server .model import Client , FlockwaveMessage
10+ from flockwave .server .show import ShowSpecification
1011
1112from .metadata import ShowMetadata
1213
@@ -55,7 +56,6 @@ def __init__(self, log: Logger):
5556 Parameter:
5657 log: logger that the middleware will write to
5758 """
58- self ._last_show_metadata = None
5959 self ._last_show_upload_command_at = monotonic () - 1000
6060 self ._log = log
6161
@@ -84,7 +84,7 @@ def __call__(self, message: FlockwaveMessage, sender: Client) -> FlockwaveMessag
8484
8585 return message
8686
87- def _extract_show (self , message : FlockwaveMessage ) -> dict [ str , Any ] | None :
87+ def _extract_show (self , message : FlockwaveMessage ) -> ShowSpecification | None :
8888 """Checks whether the given message is a show upload and extracts the
8989 show specification out of the message if it is.
9090 """
@@ -104,20 +104,21 @@ def last_show_metadata(self) -> ShowMetadata | None:
104104 return self ._last_show_metadata
105105
106106 @staticmethod
107- def _get_show_fingerprint (show : dict [ str , Any ] ) -> ShowFingerprint :
107+ def _get_show_fingerprint (show : ShowSpecification ) -> ShowFingerprint :
108108 """Extracts the basic show parameters like the origin and the orientation
109109 from the upload. These are used to decide whether an upload attempt is
110110 probably a continuation of an ongoing sequence of requests from the
111111 client or a completely new one.
112112 """
113+ show_dict = cast (dict [str , Any ], show )
113114 return [
114- get (show , "mission" , "id" ),
115- get (show , "coordinateSystem" ),
116- get (show , "amslReference" ),
115+ get (show_dict , "mission" , "id" ),
116+ get (show_dict , "coordinateSystem" ),
117+ get (show_dict , "amslReference" ),
117118 ]
118119
119120 @staticmethod
120- def _get_metadata_from_upload_request (show : dict [ str , Any ] ) -> ShowMetadata :
121+ def _get_metadata_from_upload_request (show : ShowSpecification ) -> ShowMetadata :
121122 """Extracts the metadata of the current show being uploaded. This is
122123 returned to consumers of the API of the show extension when the caller
123124 requests the metadata of the last uploaded show.
0 commit comments