File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,10 @@ async def empty(self) -> bool:
148148
149149 # TODO: it would be nice if we didn't have to list all keys here
150150 # it should be possible to stop after the first key is discovered
151- return not await self .fs ._ls (self .path )
151+ try :
152+ return not await self .fs ._ls (self .path )
153+ except FileNotFoundError :
154+ return True
152155
153156 def with_mode (self , mode : AccessModeLiteral ) -> Self :
154157 # docstring inherited
Original file line number Diff line number Diff line change @@ -186,3 +186,10 @@ def test_from_upath(self) -> None:
186186 path = UPath (f"s3://{ test_bucket_name } " , endpoint_url = endpoint_url , anon = False )
187187 result = RemoteStore .from_upath (path )
188188 assert result .fs .endpoint_url == endpoint_url
189+
190+ async def test_empty_nonexistent_path (self , store_kwargs ) -> None :
191+ # regression test for https://github.com/zarr-developers/zarr-python/pull/2343
192+ store_kwargs ["mode" ] = "w-"
193+ store_kwargs ["path" ] += "/abc"
194+ store = await self .store_cls .open (** store_kwargs )
195+ assert await store .empty ()
You can’t perform that action at this time.
0 commit comments