55import requests
66from typing_extensions import (
77 Any ,
8+ Iterable ,
89 List ,
910 Optional ,
1011 Self ,
@@ -625,7 +626,7 @@ def cloud_hosted(self, cloud_hosted: bool = True) -> Self:
625626 self .params ["provider" ] = provider
626627 return self
627628
628- def granule_name (self , granule_name : str ) -> Self :
629+ def granule_name (self , granule_name : str | Iterable [ str ] ) -> Self :
629630 """Find granules matching either granule ur or producer granule id,
630631 queries using the readable_granule_name metadata field.
631632
@@ -640,10 +641,17 @@ def granule_name(self, granule_name: str) -> Self:
640641 self
641642
642643 Raises:
643- TypeError: if `granule_name` is not of type `str`
644+ TypeError: if `granule_name` is not of type `str` or `Iterable[str]`.
644645 """
646+ if not isinstance (granule_name , Iterable ):
647+ raise TypeError (
648+ "granule_name must be of type string or Iterable of strings"
649+ )
645650 if not isinstance (granule_name , str ):
646- raise TypeError ("granule_name must be of type string" )
651+ # Convert iterable to list of strings. Since str is also Iterable, make
652+ # sure we don't do this when granule_name is a string, otherwise
653+ # we would get a list of individual characters.
654+ granule_name = [str (name ) for name in granule_name ]
647655
648656 self .params ["readable_granule_name" ] = granule_name
649657 self .params ["options[readable_granule_name][pattern]" ] = True
0 commit comments