@@ -778,7 +778,7 @@ async def _load_partial_shard_maybe(
778778 ) -> ShardMapping | None :
779779 """
780780 Read chunks from `byte_getter` for the case where the read is less than a full shard.
781- Returns a mapping of chunk coordinates to bytes.
781+ Returns a mapping of chunk coordinates to bytes or None .
782782 """
783783 shard_index = await self ._load_shard_index_maybe (byte_getter , chunks_per_shard )
784784 if shard_index is None :
@@ -788,11 +788,9 @@ async def _load_partial_shard_maybe(
788788 _ChunkCoordsByteSlice (chunk_coords , slice (* chunk_byte_slice ))
789789 for chunk_coords in all_chunk_coords
790790 # Drop chunks where index lookup fails
791- # e.g. when write_empty_chunks = False and the chunk is empty
791+ # e.g. empty chunks when write_empty_chunks = False
792792 if (chunk_byte_slice := shard_index .get_chunk_slice (chunk_coords ))
793793 ]
794- if len (chunks ) == 0 :
795- return None
796794
797795 groups = self ._coalesce_chunks (chunks )
798796
@@ -816,7 +814,7 @@ def _coalesce_chunks(
816814 ) -> list [list [_ChunkCoordsByteSlice ]]:
817815 """
818816 Combine chunks from a single shard into groups that should be read together
819- in a single request.
817+ in a single request to the store .
820818
821819 Respects the following configuration options:
822820 - `sharding.read.coalesce_max_gap_bytes`: The maximum gap between
@@ -828,6 +826,9 @@ def _coalesce_chunks(
828826
829827 sorted_chunks = sorted (chunks , key = lambda c : c .byte_slice .start )
830828
829+ if len (sorted_chunks ) == 0 :
830+ return []
831+
831832 groups = []
832833 current_group = [sorted_chunks [0 ]]
833834
0 commit comments