66from collections import namedtuple
77from datetime import datetime , timezone
88from pathlib import Path
9- from typing import Dict , Union , Iterable , List , Optional
9+ from typing import Dict , Union , Iterable , List , Optional , Any
1010from urllib .parse import urlparse
1111
1212import ndjson
@@ -203,6 +203,10 @@ def video_label_generator(self, timeout_seconds=600) -> LabelGenerator:
203203 _check_converter_import ()
204204 json_data = self .export_labels (download = True ,
205205 timeout_seconds = timeout_seconds )
206+ # assert that the instance this would fail is only if timeout runs out
207+ assert isinstance (
208+ json_data ,
209+ List ), "Unable to successfully get labels. Please try again"
206210 if json_data is None :
207211 raise TimeoutError (
208212 f"Unable to download labels in { timeout_seconds } seconds."
@@ -227,6 +231,10 @@ def label_generator(self, timeout_seconds=600) -> LabelGenerator:
227231 _check_converter_import ()
228232 json_data = self .export_labels (download = True ,
229233 timeout_seconds = timeout_seconds )
234+ # assert that the instance this would fail is only if timeout runs out
235+ assert isinstance (
236+ json_data ,
237+ List ), "Unable to successfully get labels. Please try again"
230238 if json_data is None :
231239 raise TimeoutError (
232240 f"Unable to download labels in { timeout_seconds } seconds."
@@ -241,7 +249,10 @@ def label_generator(self, timeout_seconds=600) -> LabelGenerator:
241249 "Or use project.video_label_generator() for video data." )
242250 return LBV1Converter .deserialize (json_data )
243251
244- def export_labels (self , download = False , timeout_seconds = 600 ) -> str :
252+ def export_labels (
253+ self ,
254+ download = False ,
255+ timeout_seconds = 600 ) -> Optional [Union [str , List [Dict [Any , Any ]]]]:
245256 """ Calls the server-side Label exporting that generates a JSON
246257 payload, and returns the URL to that payload.
247258
@@ -564,7 +575,7 @@ def _update_queue_mode(self, mode: QueueMode) -> QueueMode:
564575
565576 return mode
566577
567- def queue_mode (self ) -> str :
578+ def queue_mode (self ) -> QueueMode :
568579 """Provides the status of if queue mode is enabled in the project."""
569580
570581 query_str = """query %s($projectId: ID!) {
0 commit comments