@@ -579,9 +579,7 @@ def list_files(
579579 if extend and not issubclass (content_type , extend ):
580580 continue
581581
582- scope = get_output_scope (
583- content_type .scope , self .pack .pack_format if self .pack else 0
584- )
582+ scope = get_output_scope (content_type .scope , self .pack )
585583 prefix = "/" .join ((self .directory , namespace ) + scope )
586584 for name , item in container .items ():
587585 yield f"{ overlay } { prefix } /{ name } { content_type .extension } " , item
@@ -1575,9 +1573,28 @@ def list_input_scopes(scope: NamespaceFileScope) -> Iterable[Tuple[str, ...]]:
15751573 return [scope ] if isinstance (scope , tuple ) else scope .values ()
15761574
15771575
1578- def get_output_scope (scope : NamespaceFileScope , pack_format : int ) -> Tuple [str , ...]:
1576+ def get_output_scope (
1577+ scope : NamespaceFileScope , pack : Optional [int | Pack [Any ]]
1578+ ) -> Tuple [str , ...]:
15791579 if isinstance (scope , tuple ):
15801580 return scope
1581+
1582+ if pack is None :
1583+ # Fall back to the most recent scope
1584+ pack_format = 9999
1585+ elif isinstance (pack , int ):
1586+ pack_format = pack
1587+ else :
1588+ # Use the pack format from the pack's supported_formats.
1589+ # Otherwise, use the pack_format itself
1590+ if isinstance (pack .supported_formats , int ):
1591+ pack_format = pack .supported_formats
1592+ elif isinstance (pack .supported_formats , list ):
1593+ pack_format = pack .supported_formats [1 ]
1594+ elif isinstance (pack .supported_formats , dict ):
1595+ pack_format = pack .supported_formats ["max_inclusive" ]
1596+ else :
1597+ pack_format = pack .pack_format
15811598 result : Tuple [str , ...] | None = None
15821599 result_format : int | None = None
15831600 for key , value in scope .items ():
0 commit comments