panpath 0.4.1__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: panpath
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: Universal sync/async local/cloud path library with pathlib-compatible interface
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -56,7 +56,7 @@ except ImportError:
56
56
  # Azure dependencies not installed
57
57
  pass
58
58
 
59
- __version__ = "0.4.1"
59
+ __version__ = "0.4.3"
60
60
 
61
61
  __all__ = [
62
62
  "PanPath",
@@ -11,7 +11,6 @@ from panpath.clients import AsyncClient, AsyncFileHandle
11
11
  from panpath.exceptions import MissingDependencyError, NoStatError
12
12
 
13
13
  if TYPE_CHECKING:
14
- from panpath.base import PanPath
15
14
  from azure.storage.blob.aio import BlobServiceClient # type: ignore[import-not-found]
16
15
  from azure.core.exceptions import ResourceNotFoundError # type: ignore[import-not-found]
17
16
 
@@ -190,7 +189,11 @@ class AsyncAzureBlobClient(AsyncClient):
190
189
  except ResourceNotFoundError:
191
190
  raise FileNotFoundError(f"Azure blob not found: {path}")
192
191
 
193
- async def write_bytes(self, path: str, data: bytes) -> None:
192
+ async def write_bytes( # type: ignore[override]
193
+ self,
194
+ path: str,
195
+ data: bytes,
196
+ ) -> None:
194
197
  """Write bytes to Azure blob."""
195
198
  client = await self._get_client()
196
199
  container_name, blob_name = self.__class__._parse_path(path)
@@ -403,12 +406,11 @@ class AsyncAzureBlobClient(AsyncClient):
403
406
  # Set symlink metadata
404
407
  await blob_client.set_blob_metadata({self.__class__.symlink_target_metaname: target})
405
408
 
406
- async def glob(
409
+ async def glob( # type: ignore[override]
407
410
  self,
408
411
  path: str,
409
412
  pattern: str,
410
- _return_panpath: bool = True,
411
- ) -> AsyncGenerator[Union[str, "PanPath"], None]:
413
+ ) -> AsyncGenerator[str, None]:
412
414
  """Glob for files matching pattern.
413
415
 
414
416
  Args:
@@ -419,7 +421,6 @@ class AsyncAzureBlobClient(AsyncClient):
419
421
  Matching paths as strings or PanPath objects
420
422
  """
421
423
  from fnmatch import fnmatch
422
- from panpath.base import PanPath
423
424
 
424
425
  client = await self._get_client()
425
426
  container_name, blob_prefix = self.__class__._parse_path(path)
@@ -438,10 +439,7 @@ class AsyncAzureBlobClient(AsyncClient):
438
439
  if fnmatch(blob.name, f"*{file_pattern}"):
439
440
  # Determine scheme from original path
440
441
  scheme = "az" if path.startswith(f"{self.prefix[0]}://") else "azure"
441
- if not _return_panpath:
442
- yield f"{scheme}://{container_name}/{blob.name}"
443
- else:
444
- yield PanPath(f"{scheme}://{container_name}/{blob.name}")
442
+ yield f"{scheme}://{container_name}/{blob.name}"
445
443
 
446
444
  else:
447
445
  # Non-recursive - list blobs with prefix
@@ -454,18 +452,12 @@ class AsyncAzureBlobClient(AsyncClient):
454
452
  rel_name = blob.name[len(prefix_with_slash) :]
455
453
  if "/" not in rel_name and fnmatch(blob.name, f"{prefix_with_slash}{pattern}"):
456
454
  scheme = "az" if path.startswith(f"{self.prefix[0]}://") else "azure"
457
- if not _return_panpath:
458
- yield f"{scheme}://{container_name}/{blob.name}"
459
- else:
460
- yield PanPath(
461
- f"{scheme}://{container_name}/{blob.name}"
462
- )
455
+ yield f"{scheme}://{container_name}/{blob.name}"
463
456
 
464
457
  async def walk( # type: ignore[override]
465
458
  self,
466
459
  path: str,
467
- _return_panpath: bool = True,
468
- ) -> AsyncGenerator[tuple[Union[str, "PanPath"], list[str], list[str]], None]:
460
+ ) -> AsyncGenerator[tuple[str, list[str], list[str]], None]:
469
461
  """Walk directory tree.
470
462
 
471
463
  Args:
@@ -474,7 +466,6 @@ class AsyncAzureBlobClient(AsyncClient):
474
466
  Yields:
475
467
  Tuples of (dirpath, dirnames, filenames)
476
468
  """
477
- from panpath.base import PanPath
478
469
 
479
470
  client = await self._get_client()
480
471
  container_name, blob_prefix = self.__class__._parse_path(path)
@@ -528,7 +519,7 @@ class AsyncAzureBlobClient(AsyncClient):
528
519
 
529
520
  # Yield each directory tuple
530
521
  for d, (subdirs, files) in sorted(dirs.items()):
531
- yield (PanPath(d) if _return_panpath else d, sorted(subdirs), sorted(files))
522
+ yield (d, sorted(subdirs), sorted(files))
532
523
 
533
524
  async def touch( # type: ignore[no-untyped-def, override]
534
525
  self,
@@ -7,7 +7,6 @@ from panpath.clients import SyncClient, SyncFileHandle
7
7
  from panpath.exceptions import MissingDependencyError, NoStatError
8
8
 
9
9
  if TYPE_CHECKING:
10
- from panpath.base import PanPath
11
10
  from azure.storage.blob import BlobServiceClient # type: ignore[import-not-found]
12
11
  from azure.core.exceptions import ResourceNotFoundError # type: ignore[import-not-found]
13
12
 
@@ -280,12 +279,7 @@ class AzureBlobClient(SyncClient):
280
279
  # Set symlink metadata
281
280
  blob_client.set_blob_metadata({self.__class__.symlink_target_metaname: target})
282
281
 
283
- def glob( # type: ignore[override]
284
- self,
285
- path: str,
286
- pattern: str,
287
- _return_panpath: bool = True,
288
- ) -> Iterator[Union[str, "PanPath"]]:
282
+ def glob(self, path: str, pattern: str) -> Iterator[str]:
289
283
  """Glob for files matching pattern.
290
284
 
291
285
  Args:
@@ -296,7 +290,6 @@ class AzureBlobClient(SyncClient):
296
290
  List of matching CloudPath objects
297
291
  """
298
292
  from fnmatch import fnmatch
299
- from panpath.base import PanPath
300
293
 
301
294
  container_name, blob_prefix = self.__class__._parse_path(path)
302
295
  container_client = self._client.get_container_client(container_name)
@@ -317,10 +310,7 @@ class AzureBlobClient(SyncClient):
317
310
  if fnmatch(blob.name, f"*{file_pattern}"):
318
311
  # Determine scheme from original path
319
312
  scheme = "az" if path.startswith(f"{self.prefix[0]}://") else "azure"
320
- if not _return_panpath:
321
- yield f"{scheme}://{container_name}/{blob.name}"
322
- else:
323
- yield PanPath(f"{scheme}://{container_name}/{blob.name}")
313
+ yield f"{scheme}://{container_name}/{blob.name}"
324
314
  else:
325
315
  # Non-recursive - list blobs with prefix
326
316
  prefix_with_slash = (
@@ -333,16 +323,9 @@ class AzureBlobClient(SyncClient):
333
323
  rel_name = blob.name[len(prefix_with_slash) :]
334
324
  if "/" not in rel_name and fnmatch(blob.name, f"{prefix_with_slash}{pattern}"):
335
325
  scheme = "az" if path.startswith(f"{self.prefix[0]}://") else "azure"
336
- if not _return_panpath:
337
- yield f"{scheme}://{container_name}/{blob.name}"
338
- else:
339
- yield PanPath(f"{scheme}://{container_name}/{blob.name}")
326
+ yield f"{scheme}://{container_name}/{blob.name}"
340
327
 
341
- def walk(
342
- self,
343
- path: str,
344
- _return_panpath: bool = True,
345
- ) -> Iterator[tuple[Union[str, "PanPath"], list[str], list[str]]]:
328
+ def walk(self, path: str) -> Iterator[tuple[str, list[str], list[str]]]:
346
329
  """Walk directory tree.
347
330
 
348
331
  Args:
@@ -351,7 +334,6 @@ class AzureBlobClient(SyncClient):
351
334
  Yields:
352
335
  Tuples of (dirpath, dirnames, filenames)
353
336
  """
354
- from panpath.base import PanPath
355
337
 
356
338
  container_name, blob_prefix = self.__class__._parse_path(path)
357
339
  container_client = self._client.get_container_client(container_name)
@@ -404,7 +386,7 @@ class AzureBlobClient(SyncClient):
404
386
 
405
387
  # Yield each directory tuple
406
388
  for d, (subdirs, files) in sorted(dirs.items()):
407
- yield (PanPath(d) if _return_panpath else d, sorted(subdirs), sorted(files))
389
+ yield (d, sorted(subdirs), sorted(files))
408
390
 
409
391
  def touch( # type: ignore[no-untyped-def, override]
410
392
  self,
@@ -131,18 +131,6 @@ class PanPath(PathlibPath):
131
131
  Self (cloud paths are already absolute)
132
132
  """
133
133
 
134
- @abstractmethod
135
- async def a_replace(self, target: Union[str, "PathlibPath"]) -> "PanPath":
136
- """Replace file at target (overwriting if exists).
137
-
138
- Args:
139
- target: Target path
140
-
141
- Returns:
142
- New path instance
143
- """
144
- # For cloud storage, replace is same as rename (always overwrites)
145
-
146
134
  @abstractmethod
147
135
  async def a_exists(self) -> bool:
148
136
  """Asynchronously check if the path exists.
@@ -171,14 +159,14 @@ class PanPath(PathlibPath):
171
159
  """
172
160
 
173
161
  @abstractmethod
174
- async def a_write_bytes(self, data: bytes) -> int:
162
+ async def a_write_bytes(self, data: bytes) -> Union[int, None]:
175
163
  """Asynchronously write bytes to the file.
176
164
 
177
165
  Args:
178
166
  data: Bytes to write to the file.
179
167
 
180
168
  Returns:
181
- Number of bytes written.
169
+ Number of bytes written. For some cloud paths, may return None.
182
170
  """
183
171
 
184
172
  @abstractmethod
@@ -234,16 +222,22 @@ class PanPath(PathlibPath):
234
222
  """
235
223
 
236
224
  @abstractmethod
237
- async def a_mkdir(self, mode: int = 0o777, parents: bool = False) -> None:
225
+ async def a_mkdir(
226
+ self,
227
+ mode: int = 0o777,
228
+ parents: bool = False,
229
+ exist_ok: bool = False,
230
+ ) -> None:
238
231
  """Asynchronously create a directory at this path.
239
232
 
240
233
  Args:
241
234
  mode: Directory mode (permissions) to set.
242
235
  parents: If True, create parent directories as needed.
236
+ exist_ok: If True, does not raise an error if the directory already exists.
243
237
  """
244
238
 
245
239
  @abstractmethod
246
- async def a_glob(self, pattern: str) -> List["PanPath"]:
240
+ async def a_glob(self, pattern: str) -> AsyncGenerator["PanPath", None]:
247
241
  """Asynchronously yield paths matching a glob pattern.
248
242
 
249
243
  Args:
@@ -254,7 +248,7 @@ class PanPath(PathlibPath):
254
248
  """
255
249
 
256
250
  @abstractmethod
257
- async def a_rglob(self, pattern: str) -> List["PanPath"]:
251
+ async def a_rglob(self, pattern: str) -> AsyncGenerator["PanPath", None]:
258
252
  """Asynchronously yield paths matching a recursive glob pattern.
259
253
 
260
254
  Args:
@@ -2,7 +2,6 @@
2
2
 
3
3
  from abc import ABC, abstractmethod
4
4
  from typing import (
5
- TYPE_CHECKING,
6
5
  Any,
7
6
  AsyncGenerator,
8
7
  Callable,
@@ -16,9 +15,6 @@ from typing import (
16
15
 
17
16
  import re
18
17
 
19
- if TYPE_CHECKING:
20
- from panpath.base import PanPath
21
-
22
18
 
23
19
  class Client(ABC):
24
20
  """Base class for cloud storage clients."""
@@ -112,11 +108,7 @@ class SyncClient(Client, ABC):
112
108
  """Find all paths matching pattern."""
113
109
 
114
110
  @abstractmethod
115
- def walk(
116
- self,
117
- path: str,
118
- _return_panpath: True,
119
- ) -> Iterator[tuple[Union[str, "PanPath"], list[str], list[str]]]:
111
+ def walk(self, path: str) -> Iterator[tuple[str, list[str], list[str]]]:
120
112
  """Walk directory tree."""
121
113
 
122
114
  @abstractmethod
@@ -222,7 +214,7 @@ class AsyncClient(Client, ABC):
222
214
  """Read file as bytes."""
223
215
 
224
216
  @abstractmethod
225
- async def write_bytes(self, path: str, data: bytes) -> None:
217
+ async def write_bytes(self, path: str, data: bytes) -> int:
226
218
  """Write bytes to file."""
227
219
 
228
220
  @abstractmethod
@@ -257,8 +249,7 @@ class AsyncClient(Client, ABC):
257
249
  async def walk(
258
250
  self,
259
251
  path: str,
260
- _return_panpath: bool = True,
261
- ) -> AsyncGenerator[tuple[Union[str, "PanPath"], list[str], list[str]], None]:
252
+ ) -> AsyncGenerator[tuple[str, list[str], list[str]], None]:
262
253
  """Walk directory tree."""
263
254
 
264
255
  @abstractmethod
@@ -312,9 +303,9 @@ class AsyncClient(Client, ABC):
312
303
  data = await self.read_bytes(path)
313
304
  return data.decode(encoding)
314
305
 
315
- async def write_text(self, path: str, data: str, encoding: str = "utf-8") -> None:
306
+ async def write_text(self, path: str, data: str, encoding: str = "utf-8") -> int:
316
307
  """Write text to Azure blob."""
317
- await self.write_bytes(path, data.encode(encoding))
308
+ return await self.write_bytes(path, data.encode(encoding))
318
309
 
319
310
  async def is_symlink(self, path: str) -> bool:
320
311
  """Check if path is a symlink (has symlink metadata).
@@ -19,6 +19,7 @@ from typing import (
19
19
  from panpath.base import PanPath
20
20
 
21
21
  if TYPE_CHECKING:
22
+ from pathlib import Path
22
23
  from panpath.clients import AsyncClient, AsyncFileHandle, SyncClient
23
24
 
24
25
 
@@ -263,7 +264,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
263
264
  # Use PurePosixPath's match which handles ** correctly
264
265
  return key_path.match(pattern)
265
266
 
266
- def glob(self, pattern: str) -> List["CloudPath"]: # type: ignore[override]
267
+ def glob(self, pattern: str) -> Iterator["CloudPath"]: # type: ignore[override]
267
268
  """Glob for files matching pattern.
268
269
 
269
270
  Args:
@@ -272,9 +273,10 @@ class CloudPath(PanPath, PurePosixPath, ABC):
272
273
  Returns:
273
274
  List of matching paths
274
275
  """
275
- return self.client.glob(str(self), pattern) # type: ignore[return-value]
276
+ for p in self.client.glob(str(self), pattern):
277
+ yield self._new_cloudpath(p)
276
278
 
277
- def rglob(self, pattern: str) -> List["CloudPath"]: # type: ignore[override]
279
+ def rglob(self, pattern: str) -> Iterator["CloudPath"]: # type: ignore[override]
278
280
  """Recursively glob for files matching pattern.
279
281
 
280
282
  Args:
@@ -283,15 +285,16 @@ class CloudPath(PanPath, PurePosixPath, ABC):
283
285
  Returns:
284
286
  List of matching paths (recursive)
285
287
  """
286
- return self.glob(f"**/{pattern}")
288
+ yield from self.glob(f"**/{pattern}")
287
289
 
288
- def walk(self) -> List[Tuple[str, List[str], List[str]]]:
290
+ def walk(self) -> Iterator[Tuple["CloudPath", List[str], List[str]]]:
289
291
  """Walk directory tree (like os.walk).
290
292
 
291
293
  Returns:
292
294
  List of (dirpath, dirnames, filenames) tuples
293
295
  """
294
- return self.client.walk(str(self)) # type: ignore[return-value]
296
+ for d, subdirs, files in self.client.walk(str(self)):
297
+ yield self._new_cloudpath(d), subdirs, files
295
298
 
296
299
  def touch(self, exist_ok: bool = True) -> None: # type: ignore[override]
297
300
  """Create empty file.
@@ -461,8 +464,8 @@ class CloudPath(PanPath, PurePosixPath, ABC):
461
464
  src: str, dst: str, follow_symlinks: bool = True
462
465
  ) -> None: # pragma: no cover
463
466
  """Copy file across storage boundaries."""
464
- src_path = PanPath(src)
465
- dst_path = PanPath(dst)
467
+ src_path = PanPath(src) # type: ignore[abstract]
468
+ dst_path = PanPath(dst) # type: ignore[abstract]
466
469
 
467
470
  # Handle symlinks
468
471
  if not follow_symlinks and src_path.is_symlink():
@@ -479,8 +482,8 @@ class CloudPath(PanPath, PurePosixPath, ABC):
479
482
  src: str, dst: str, follow_symlinks: bool = True
480
483
  ) -> None: # pragma: no cover
481
484
  """Copy directory tree across storage boundaries."""
482
- src_path = PanPath(src)
483
- dst_path = PanPath(dst)
485
+ src_path = PanPath(src) # type: ignore[abstract]
486
+ dst_path = PanPath(dst) # type: ignore[abstract]
484
487
 
485
488
  # Create destination directory
486
489
  dst_path.mkdir(parents=True, exist_ok=True)
@@ -497,7 +500,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
497
500
 
498
501
  # Copy files
499
502
  for filename in filenames:
500
- src_file = PanPath(dirpath) / filename
503
+ src_file = PanPath(dirpath) / filename # type: ignore[abstract]
501
504
  dst_file = dst_path / rel_dir / filename if rel_dir else dst_path / filename
502
505
  # Handle symlinks
503
506
  if not follow_symlinks and src_file.is_symlink():
@@ -521,13 +524,16 @@ class CloudPath(PanPath, PurePosixPath, ABC):
521
524
  """Read file as text."""
522
525
  return await self.async_client.read_text(str(self), encoding=encoding)
523
526
 
524
- async def a_write_bytes(self, data: bytes) -> None:
527
+ async def a_write_bytes(
528
+ self,
529
+ data: bytes,
530
+ ) -> None:
525
531
  """Write bytes to file."""
526
532
  await self.async_client.write_bytes(str(self), data)
527
533
 
528
- async def a_write_text(self, data: str, encoding: str = "utf-8") -> None:
534
+ async def a_write_text(self, data: str, encoding: str = "utf-8") -> int:
529
535
  """Write text to file."""
530
- await self.async_client.write_text(str(self), data, encoding=encoding)
536
+ return await self.async_client.write_text(str(self), data, encoding=encoding)
531
537
 
532
538
  async def a_unlink(self, missing_ok: bool = False) -> None:
533
539
  """Delete file."""
@@ -537,7 +543,9 @@ class CloudPath(PanPath, PurePosixPath, ABC):
537
543
  if not missing_ok:
538
544
  raise
539
545
 
540
- async def a_iterdir(self) -> AsyncGenerator["CloudPath", None]:
546
+ async def a_iterdir( # type: ignore[override]
547
+ self,
548
+ ) -> AsyncGenerator["CloudPath", None]:
541
549
  """List directory contents (async version returns list)."""
542
550
  for item in await self.async_client.list_dir(str(self)):
543
551
  yield self._new_cloudpath(item)
@@ -555,7 +563,10 @@ class CloudPath(PanPath, PurePosixPath, ABC):
555
563
  return await self.async_client.stat(str(self))
556
564
 
557
565
  async def a_mkdir(
558
- self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False
566
+ self,
567
+ mode: int = 0o777,
568
+ parents: bool = False,
569
+ exist_ok: bool = False,
559
570
  ) -> None:
560
571
  """Create a directory marker in cloud storage.
561
572
 
@@ -569,7 +580,10 @@ class CloudPath(PanPath, PurePosixPath, ABC):
569
580
  """
570
581
  await self.async_client.mkdir(str(self), parents=parents, exist_ok=exist_ok)
571
582
 
572
- async def a_glob(self, pattern: str) -> List["CloudPath"]:
583
+ async def a_glob( # type: ignore[override]
584
+ self,
585
+ pattern: str,
586
+ ) -> AsyncGenerator["CloudPath", None]:
573
587
  """Glob for files matching pattern.
574
588
 
575
589
  Args:
@@ -578,9 +592,13 @@ class CloudPath(PanPath, PurePosixPath, ABC):
578
592
  Returns:
579
593
  List of matching paths
580
594
  """
581
- return await self.async_client.glob(str(self), pattern) # type: ignore[return-value]
595
+ async for p in self.async_client.glob(str(self), pattern): # type: ignore[attr-defined]
596
+ yield self._new_cloudpath(p)
582
597
 
583
- async def a_rglob(self, pattern: str) -> List["CloudPath"]:
598
+ async def a_rglob( # type: ignore[override]
599
+ self,
600
+ pattern: str,
601
+ ) -> AsyncGenerator["CloudPath", None]:
584
602
  """Recursively glob for files matching pattern.
585
603
 
586
604
  Args:
@@ -589,17 +607,27 @@ class CloudPath(PanPath, PurePosixPath, ABC):
589
607
  Returns:
590
608
  List of matching paths (recursive)
591
609
  """
592
- return await self.a_glob(f"**/{pattern}")
610
+ async for p in self.a_glob(f"**/{pattern}"):
611
+ yield p
593
612
 
594
- async def a_walk(self) -> List[Tuple[str, List[str], List[str]]]:
613
+ async def a_walk( # type: ignore[override]
614
+ self,
615
+ ) -> AsyncGenerator[Tuple["CloudPath", List[str], List[str]], None]:
595
616
  """Walk directory tree (like os.walk).
596
617
 
597
618
  Returns:
598
619
  List of (dirpath, dirnames, filenames) tuples
599
620
  """
600
- return await self.async_client.walk(str(self))
621
+ async for d, subdirs, files in self.async_client.walk( # type: ignore[attr-defined]
622
+ str(self)
623
+ ):
624
+ yield self._new_cloudpath(d), subdirs, files
601
625
 
602
- async def a_touch(self, exist_ok: bool = True) -> None:
626
+ async def a_touch(
627
+ self,
628
+ mode: int = 0o666,
629
+ exist_ok: bool = True,
630
+ ) -> None:
603
631
  """Create empty file.
604
632
 
605
633
  Args:
@@ -607,7 +635,10 @@ class CloudPath(PanPath, PurePosixPath, ABC):
607
635
  """
608
636
  await self.async_client.touch(str(self), exist_ok=exist_ok)
609
637
 
610
- async def a_rename(self, target: Union[str, "CloudPath"]) -> "CloudPath":
638
+ async def a_rename( # type: ignore[override]
639
+ self,
640
+ target: Union[str, "CloudPath"],
641
+ ) -> "CloudPath":
611
642
  """Rename/move file to target.
612
643
 
613
644
  Can move between cloud and local paths.
@@ -623,11 +654,11 @@ class CloudPath(PanPath, PurePosixPath, ABC):
623
654
 
624
655
  target_str = str(target)
625
656
  if not isinstance(target, PanPath): # pragma: no cover
626
- target = PanPath(target_str)
657
+ target = PanPath(target_str) # type: ignore[abstract, assignment]
627
658
 
628
659
  source_is_dir = await self.a_is_dir()
629
- target_is_dir = await target.a_is_dir()
630
- target_exists = await target.a_exists()
660
+ target_is_dir = await target.a_is_dir() # type: ignore[union-attr]
661
+ target_exists = await target.a_exists() # type: ignore[union-attr]
631
662
  if source_is_dir and not target_is_dir and target_exists:
632
663
  raise NotADirectoryError(
633
664
  f"Cannot rename directory {self} to non-directory target {target}"
@@ -637,7 +668,10 @@ class CloudPath(PanPath, PurePosixPath, ABC):
637
668
 
638
669
  if source_is_dir:
639
670
  if not target_exists:
640
- await target.a_mkdir(parents=True, exist_ok=True)
671
+ await target.a_mkdir( # type: ignore[union-attr]
672
+ parents=True,
673
+ exist_ok=True,
674
+ )
641
675
 
642
676
  # Support renaming directories by copying contents
643
677
  async for item in self.a_iterdir():
@@ -645,7 +679,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
645
679
  new_target = target / relative_path
646
680
  await item.a_rename(new_target)
647
681
  await self.a_rmdir()
648
- return target
682
+ return target # type: ignore[return-value]
649
683
 
650
684
  # Check if cross-storage operation
651
685
  if CloudPath._is_cross_storage_op(str(self), target_str): # pragma: no cover
@@ -658,7 +692,10 @@ class CloudPath(PanPath, PurePosixPath, ABC):
658
692
 
659
693
  return PanPath(target_str) # type: ignore
660
694
 
661
- async def a_replace(self, target: Union[str, "CloudPath"]) -> "CloudPath":
695
+ async def a_replace( # type: ignore[override]
696
+ self,
697
+ target: Union[str, "CloudPath"],
698
+ ) -> "CloudPath":
662
699
  """Replace file at target (overwriting if exists).
663
700
 
664
701
  Args:
@@ -700,7 +737,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
700
737
 
701
738
  return PanPath(target) # type: ignore
702
739
 
703
- async def a_symlink_to(
740
+ async def a_symlink_to( # type: ignore[override]
704
741
  self,
705
742
  target: Union[str, "CloudPath"],
706
743
  target_is_directory: bool = False,
@@ -727,9 +764,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
727
764
  """
728
765
  await self.async_client.rmtree(str(self), ignore_errors=ignore_errors, onerror=onerror)
729
766
 
730
- async def a_copy(
731
- self, target: Union[str, "CloudPath"], follow_symlinks: bool = True
732
- ) -> "PanPath":
767
+ async def a_copy(self, target: Union[str, "Path"], follow_symlinks: bool = True) -> "PanPath":
733
768
  """Copy file to target.
734
769
 
735
770
  Can copy between cloud and local paths.
@@ -748,10 +783,12 @@ class CloudPath(PanPath, PurePosixPath, ABC):
748
783
  # Same storage, use native copy
749
784
  await self.async_client.copy(str(self), target_str, follow_symlinks=follow_symlinks)
750
785
 
751
- return PanPath(target_str)
786
+ return PanPath(target_str) # type: ignore[abstract]
752
787
 
753
788
  async def a_copytree(
754
- self, target: Union[str, "CloudPath"], follow_symlinks: bool = True
789
+ self,
790
+ target: Union[str, "Path"],
791
+ follow_symlinks: bool = True,
755
792
  ) -> "CloudPath":
756
793
  """Copy directory tree to target recursively.
757
794
 
@@ -781,29 +818,29 @@ class CloudPath(PanPath, PurePosixPath, ABC):
781
818
  src: str, dst: str, follow_symlinks: bool = True
782
819
  ) -> None: # pragma: no cover
783
820
  """Copy file across storage boundaries (async)."""
784
- src_path = PanPath(src)
785
- dst_path = PanPath(dst)
821
+ src_path = PanPath(src) # type: ignore[abstract]
822
+ dst_path = PanPath(dst) # type: ignore[abstract]
786
823
 
787
824
  # Handle symlinks
788
- if not follow_symlinks and await src_path.a_is_symlink(): # type: ignore[attr-defined]
825
+ if not follow_symlinks and await src_path.a_is_symlink():
789
826
  # Copy as symlink
790
- target = await src_path.a_readlink() # type: ignore[attr-defined]
791
- await dst_path.a_symlink_to(str(target)) # type: ignore[attr-defined]
827
+ target = await src_path.a_readlink()
828
+ await dst_path.a_symlink_to(str(target))
792
829
  else:
793
830
  # Read from source and write to destination
794
- data = await src_path.a_read_bytes() # type: ignore[attr-defined]
795
- await dst_path.a_write_bytes(data) # type: ignore[attr-defined]
831
+ data = await src_path.a_read_bytes()
832
+ await dst_path.a_write_bytes(data)
796
833
 
797
834
  @staticmethod
798
835
  async def _a_copytree_cross_storage(
799
836
  src: str, dst: str, follow_symlinks: bool = True
800
837
  ) -> None: # pragma: no cover
801
838
  """Copy directory tree across storage boundaries (async)."""
802
- src_path = PanPath(src)
803
- dst_path = PanPath(dst)
839
+ src_path = PanPath(src) # type: ignore[abstract]
840
+ dst_path = PanPath(dst) # type: ignore[abstract]
804
841
 
805
842
  # Create destination directory
806
- await dst_path.a_mkdir(parents=True, exist_ok=True) # type: ignore[attr-defined]
843
+ await dst_path.a_mkdir(parents=True, exist_ok=True)
807
844
 
808
845
  # Walk source tree and copy all files
809
846
  for dirpath, dirnames, filenames in await src_path.a_walk(): # type: ignore[attr-defined]
@@ -817,7 +854,7 @@ class CloudPath(PanPath, PurePosixPath, ABC):
817
854
 
818
855
  # Copy files
819
856
  for filename in filenames:
820
- src_file = PanPath(dirpath) / filename
857
+ src_file = PanPath(dirpath) / filename # type: ignore[abstract]
821
858
  dst_file = dst_path / rel_dir / filename if rel_dir else dst_path / filename
822
859
  # Handle symlinks
823
860
  if not follow_symlinks and await src_file.a_is_symlink():
@@ -13,7 +13,6 @@ from panpath.clients import AsyncClient, AsyncFileHandle
13
13
  from panpath.exceptions import MissingDependencyError, NoStatError
14
14
 
15
15
  if TYPE_CHECKING:
16
- from panpath.base import PanPath
17
16
  from gcloud.aio.storage import Storage
18
17
 
19
18
  try:
@@ -184,7 +183,11 @@ class AsyncGSClient(AsyncClient):
184
183
  except Exception as e:
185
184
  raise FileNotFoundError(f"GCS blob not found: {path}") from e
186
185
 
187
- async def write_bytes(self, path: str, data: bytes) -> None:
186
+ async def write_bytes( # type: ignore[override]
187
+ self,
188
+ path: str,
189
+ data: bytes,
190
+ ) -> None:
188
191
  """Write bytes to GCS blob."""
189
192
  storage = await self._get_client()
190
193
  bucket_name, blob_name = self.__class__._parse_path(path)
@@ -441,24 +444,21 @@ class AsyncGSClient(AsyncClient):
441
444
  # Then set the symlink metadata
442
445
  await self.set_metadata(path, {self.__class__.symlink_target_metaname: target})
443
446
 
444
- async def glob(
447
+ async def glob( # type: ignore[override]
445
448
  self,
446
449
  path: str,
447
450
  pattern: str,
448
- _return_panpath: bool = True,
449
- ) -> AsyncGenerator[Union[str, "PanPath"], None]:
451
+ ) -> AsyncGenerator[str, None]:
450
452
  """Glob for files matching pattern.
451
453
 
452
454
  Args:
453
455
  path: Base GCS path
454
456
  pattern: Glob pattern (e.g., "*.txt", "**/*.py")
455
- _return_panpath: If True, return PanPath objects; otherwise return strings
456
457
 
457
458
  Returns:
458
459
  List of matching PanPath objects or strings
459
460
  """
460
461
  from fnmatch import fnmatch
461
- from panpath.base import PanPath
462
462
 
463
463
  bucket_name, prefix = self.__class__._parse_path(path)
464
464
  storage = await self._get_client()
@@ -482,10 +482,7 @@ class AsyncGSClient(AsyncClient):
482
482
  for item in items:
483
483
  blob_name = item["name"]
484
484
  if fnmatch(blob_name, f"*{file_pattern}"):
485
- if not _return_panpath:
486
- yield f"{self.prefix[0]}://{bucket_name}/{blob_name}"
487
- else:
488
- yield PanPath(f"{self.prefix[0]}://{bucket_name}/{blob_name}")
485
+ yield f"{self.prefix[0]}://{bucket_name}/{blob_name}"
489
486
  else:
490
487
  # Non-recursive - list blobs with delimiter
491
488
  blob_prefix = f"{prefix}/" if prefix and not prefix.endswith("/") else prefix
@@ -499,17 +496,13 @@ class AsyncGSClient(AsyncClient):
499
496
 
500
497
  for item in items:
501
498
  blob_name = item["name"]
502
- if fnmatch(blob_name, f"{prefix}{pattern}"):
503
- if not _return_panpath:
504
- yield f"{self.prefix[0]}://{bucket_name}/{blob_name}"
505
- else:
506
- yield PanPath(f"{self.prefix[0]}://{bucket_name}/{blob_name}")
499
+ if fnmatch(blob_name, f"{blob_prefix}{pattern}"):
500
+ yield f"{self.prefix[0]}://{bucket_name}/{blob_name}"
507
501
 
508
502
  async def walk( # type: ignore[override]
509
503
  self,
510
504
  path: str,
511
- _return_panpath: bool = True,
512
- ) -> AsyncGenerator[tuple[Union[str, "PanPath"], list[str], list[str]], None]:
505
+ ) -> AsyncGenerator[tuple[str, list[str], list[str]], None]:
513
506
  """Walk directory tree.
514
507
 
515
508
  Args:
@@ -518,7 +511,6 @@ class AsyncGSClient(AsyncClient):
518
511
  Yields:
519
512
  Tuples of (dirpath, dirnames, filenames)
520
513
  """
521
- from panpath.base import PanPath
522
514
 
523
515
  bucket_name, blob_prefix = self.__class__._parse_path(path)
524
516
  storage = await self._get_client()
@@ -578,7 +570,7 @@ class AsyncGSClient(AsyncClient):
578
570
 
579
571
  # Yield each directory tuple
580
572
  for d, (subdirs, files) in sorted(dirs.items()):
581
- yield (PanPath(d) if _return_panpath else d, sorted(subdirs), sorted(files))
573
+ yield (d, sorted(subdirs), sorted(files))
582
574
 
583
575
  async def touch( # type: ignore[no-untyped-def, override]
584
576
  self,
@@ -11,7 +11,6 @@ from panpath.exceptions import MissingDependencyError, NoStatError
11
11
  if TYPE_CHECKING:
12
12
  from google.cloud import storage # type: ignore[import-untyped, unused-ignore]
13
13
  from google.api_core.exceptions import NotFound
14
- from panpath.base import PanPath
15
14
 
16
15
  try:
17
16
  with warnings.catch_warnings():
@@ -313,24 +312,17 @@ class GSClient(SyncClient):
313
312
  path = path.rstrip("/").rsplit("/", 1)[0]
314
313
  return f"{path}/{target}"
315
314
 
316
- def glob( # type: ignore[override]
317
- self,
318
- path: str,
319
- pattern: str,
320
- _return_panpath: bool = False,
321
- ) -> Iterator[Union[str, "PanPath"]]:
315
+ def glob(self, path: str, pattern: str) -> Iterator[str]:
322
316
  """Glob for files matching pattern.
323
317
 
324
318
  Args:
325
319
  path: Base GCS path
326
320
  pattern: Glob pattern (e.g., "*.txt", "**/*.py")
327
- _return_panpath: If True, return PanPath objects; if False, return strings
328
321
 
329
322
  Returns:
330
323
  List of matching paths (as PanPath objects or strings)
331
324
  """
332
325
  from fnmatch import fnmatch
333
- from panpath.base import PanPath
334
326
 
335
327
  bucket_name, blob_prefix = self.__class__._parse_path(path)
336
328
  bucket = self._client.bucket(bucket_name)
@@ -351,10 +343,7 @@ class GSClient(SyncClient):
351
343
  for blob in blobs:
352
344
  if fnmatch(blob.name, f"*{file_pattern}"):
353
345
  path_str = f"{self.prefix[0]}://{bucket_name}/{blob.name}"
354
- if _return_panpath:
355
- yield PanPath(path_str)
356
- else: # pragma: no cover
357
- yield path_str
346
+ yield path_str
358
347
  else:
359
348
  # Non-recursive - list blobs with delimiter
360
349
  prefix = (
@@ -365,12 +354,9 @@ class GSClient(SyncClient):
365
354
  for blob in blobs:
366
355
  if fnmatch(blob.name, f"{prefix}{pattern}"):
367
356
  path_str = f"{self.prefix[0]}://{bucket_name}/{blob.name}"
368
- if _return_panpath:
369
- yield PanPath(path_str)
370
- else: # pragma: no cover
371
- yield path_str
357
+ yield path_str
372
358
 
373
- def walk( # type: ignore[override]
359
+ def walk(
374
360
  self,
375
361
  path: str,
376
362
  ) -> Iterator[tuple[str, list[str], list[str]]]:
@@ -79,7 +79,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
79
79
 
80
80
  target_str = str(target)
81
81
  await aiofiles.os.rename(str(self), target_str)
82
- return PanPath(target_str)
82
+ return PanPath(target_str) # type: ignore[abstract]
83
83
 
84
84
  async def a_replace(self, target: Union[str, "Path"]) -> "PanPath":
85
85
  """Rename the file or directory to target, overwriting if target exists.
@@ -131,7 +131,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
131
131
  break
132
132
  await df.write(chunk)
133
133
 
134
- return PanPath(target_str)
134
+ return PanPath(target_str) # type: ignore[abstract]
135
135
 
136
136
  async def a_copytree(
137
137
  self,
@@ -154,7 +154,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
154
154
  extra="all-async",
155
155
  )
156
156
 
157
- target = PanPath(target)
157
+ target = PanPath(target) # type: ignore[abstract]
158
158
  await target.a_mkdir(parents=True, exist_ok=True)
159
159
 
160
160
  async for entry in self.a_iterdir():
@@ -168,7 +168,9 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
168
168
 
169
169
  return target
170
170
 
171
- async def a_walk(self) -> AsyncGenerator[Tuple["LocalPath", List[str], List[str]], None]:
171
+ async def a_walk( # type: ignore[override]
172
+ self,
173
+ ) -> AsyncGenerator[Tuple["LocalPath", List[str], List[str]], None]:
172
174
  """Asynchronously walk the directory tree.
173
175
 
174
176
  Returns:
@@ -205,7 +207,9 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
205
207
  extra="all-async",
206
208
  )
207
209
 
208
- return PanPath(await aiofiles.os.readlink(str(self)))
210
+ return PanPath( # type: ignore[return-value, abstract]
211
+ await aiofiles.os.readlink(str(self))
212
+ )
209
213
 
210
214
  async def a_symlink_to(
211
215
  self,
@@ -227,7 +231,10 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
227
231
 
228
232
  await aiofiles.os.symlink(str(target), str(self), target_is_directory=target_is_directory)
229
233
 
230
- async def a_glob(self, pattern: str) -> AsyncGenerator["LocalPath", None]:
234
+ async def a_glob( # type: ignore[override]
235
+ self,
236
+ pattern: str,
237
+ ) -> AsyncGenerator["LocalPath", None]:
231
238
  """Asynchronously yield paths matching the glob pattern.
232
239
 
233
240
  Args:
@@ -265,7 +272,10 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
265
272
  if fnmatch(entry.name, pattern):
266
273
  yield entry
267
274
 
268
- async def a_rglob(self, pattern: str) -> AsyncGenerator["LocalPath", None]:
275
+ async def a_rglob( # type: ignore[override]
276
+ self,
277
+ pattern: str,
278
+ ) -> AsyncGenerator["LocalPath", None]:
269
279
  """Recursively yield all existing files matching the given pattern.
270
280
 
271
281
  Args:
@@ -345,7 +355,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
345
355
  async with aiofiles.open(str(self), mode="r", encoding=encoding) as f:
346
356
  return await f.read() # type: ignore[no-any-return]
347
357
 
348
- async def a_write_bytes(self, data: bytes) -> None:
358
+ async def a_write_bytes(self, data: bytes) -> int:
349
359
  """Write bytes to file (async)."""
350
360
  if not HAS_AIOFILES:
351
361
  raise MissingDependencyError(
@@ -355,9 +365,9 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
355
365
  )
356
366
 
357
367
  async with aiofiles.open(str(self), mode="wb") as f:
358
- await f.write(data)
368
+ return await f.write(data) # type: ignore[no-any-return]
359
369
 
360
- async def a_write_text(self, data: str, encoding: str = "utf-8") -> None:
370
+ async def a_write_text(self, data: str, encoding: str = "utf-8") -> int:
361
371
  """Write text to file (async)."""
362
372
  if not HAS_AIOFILES:
363
373
  raise MissingDependencyError(
@@ -367,7 +377,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
367
377
  )
368
378
 
369
379
  async with aiofiles.open(str(self), mode="w", encoding=encoding) as f:
370
- await f.write(data)
380
+ return await f.write(data) # type: ignore[no-any-return]
371
381
 
372
382
  async def a_is_symlink(self) -> bool:
373
383
  """Check if path is a symlink (async)."""
@@ -396,7 +406,10 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
396
406
  raise
397
407
 
398
408
  async def a_mkdir(
399
- self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False
409
+ self,
410
+ mode: int = 0o777,
411
+ parents: bool = False,
412
+ exist_ok: bool = False,
400
413
  ) -> None:
401
414
  """Create directory (async)."""
402
415
  if not HAS_AIOFILES:
@@ -426,7 +439,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
426
439
 
427
440
  await aiofiles.os.rmdir(str(self))
428
441
 
429
- async def a_rmtree(self) -> None:
442
+ async def a_rmtree(self) -> None: # type: ignore[override]
430
443
  """Recursively remove directory and its contents (async)."""
431
444
  if not HAS_AIOFILES:
432
445
  raise MissingDependencyError(
@@ -443,7 +456,9 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
443
456
  await aiofiles.os.remove(str(path))
444
457
  await aiofiles.os.rmdir(str(self))
445
458
 
446
- async def a_iterdir(self) -> AsyncGenerator["LocalPath", None]:
459
+ async def a_iterdir( # type: ignore[override]
460
+ self,
461
+ ) -> AsyncGenerator["LocalPath", None]:
447
462
  """List directory contents (async)."""
448
463
  if not HAS_AIOFILES:
449
464
  raise MissingDependencyError(
@@ -466,7 +481,7 @@ class LocalPath(_ConcretePath, PanPath): # type: ignore[valid-type, misc]
466
481
 
467
482
  return await aiofiles.os.stat(str(self)) # type: ignore[no-any-return]
468
483
 
469
- def a_open(
484
+ def a_open( # type: ignore[override]
470
485
  self,
471
486
  mode: str = "r",
472
487
  buffering: int = -1,
@@ -13,7 +13,6 @@ from panpath.exceptions import MissingDependencyError, NoStatError
13
13
 
14
14
  if TYPE_CHECKING:
15
15
  import aioboto3 # type: ignore[import-not-found]
16
- from panpath.base import PanPath
17
16
  from aiobotocore.client import AioBaseClient # type: ignore[import-untyped, unused-ignore]
18
17
  from botocore.exceptions import ClientError # type: ignore[import-untyped, unused-ignore]
19
18
 
@@ -184,7 +183,11 @@ class AsyncS3Client(AsyncClient):
184
183
  raise FileNotFoundError(f"S3 object not found: {path}")
185
184
  raise
186
185
 
187
- async def write_bytes(self, path: str, data: bytes) -> None:
186
+ async def write_bytes( # type: ignore[override]
187
+ self,
188
+ path: str,
189
+ data: bytes,
190
+ ) -> None:
188
191
  """Write bytes to S3 object."""
189
192
  bucket, key = self.__class__._parse_path(path)
190
193
  client = await self._get_client()
@@ -444,24 +447,21 @@ class AsyncS3Client(AsyncClient):
444
447
  Metadata={self.__class__.symlink_target_metaname: target},
445
448
  )
446
449
 
447
- async def glob(
450
+ async def glob( # type: ignore[override]
448
451
  self,
449
452
  path: str,
450
453
  pattern: str,
451
- _return_panpath: bool = False,
452
- ) -> AsyncGenerator[Union[str, "PanPath"], None]:
454
+ ) -> AsyncGenerator[str, None]:
453
455
  """Glob for files matching pattern.
454
456
 
455
457
  Args:
456
458
  path: Base S3 path
457
459
  pattern: Glob pattern (e.g., "*.txt", "**/*.py")
458
- _return_panpath: If True, return PanPath objects; if False, return strings
459
460
 
460
461
  Returns:
461
462
  List of matching paths (as PanPath objects or strings)
462
463
  """
463
464
  from fnmatch import fnmatch
464
- from panpath.base import PanPath
465
465
 
466
466
  bucket, prefix = self.__class__._parse_path(path)
467
467
 
@@ -484,10 +484,7 @@ class AsyncS3Client(AsyncClient):
484
484
  key = obj["Key"]
485
485
  if fnmatch(key, f"*{file_pattern}"):
486
486
  path_str = f"{self.prefix[0]}://{bucket}/{key}"
487
- if _return_panpath:
488
- yield PanPath(path_str)
489
- else:
490
- yield path_str
487
+ yield path_str
491
488
  else:
492
489
  # Non-recursive - list objects with delimiter
493
490
  prefix_with_slash = f"{prefix}/" if prefix and not prefix.endswith("/") else prefix
@@ -499,16 +496,12 @@ class AsyncS3Client(AsyncClient):
499
496
  key = obj["Key"]
500
497
  if fnmatch(key, f"{prefix_with_slash}{pattern}"):
501
498
  path_str = f"{self.prefix[0]}://{bucket}/{key}"
502
- if _return_panpath:
503
- yield PanPath(path_str)
504
- else:
505
- yield path_str
499
+ yield path_str
506
500
 
507
501
  async def walk( # type: ignore[override]
508
502
  self,
509
503
  path: str,
510
- _return_panpath: bool = True,
511
- ) -> AsyncGenerator[tuple[Union[str, "PanPath"], list[str], list[str]], None]:
504
+ ) -> AsyncGenerator[tuple[str, list[str], list[str]], None]:
512
505
  """Walk directory tree.
513
506
 
514
507
  Args:
@@ -517,8 +510,6 @@ class AsyncS3Client(AsyncClient):
517
510
  Yields:
518
511
  Tuples of (dirpath, dirnames, filenames)
519
512
  """
520
- from panpath.base import PanPath
521
-
522
513
  bucket, prefix = self.__class__._parse_path(path)
523
514
 
524
515
  # List all objects under prefix
@@ -576,7 +567,7 @@ class AsyncS3Client(AsyncClient):
576
567
 
577
568
  # Yield tuples
578
569
  for d, (subdirs, files) in sorted(dirs.items()):
579
- yield (PanPath(d) if _return_panpath else d, sorted(subdirs), sorted(files))
570
+ yield (d, sorted(subdirs), sorted(files))
580
571
 
581
572
  async def touch(self, path: str, exist_ok: bool = True, mode: Optional[int] = None) -> None:
582
573
  """Create empty file.
@@ -10,7 +10,6 @@ from panpath.exceptions import MissingDependencyError
10
10
  if TYPE_CHECKING:
11
11
  import boto3 # type: ignore[import-untyped]
12
12
  from botocore.exceptions import ClientError # type: ignore[import-untyped]
13
- from panpath.base import PanPath
14
13
 
15
14
  try:
16
15
  import boto3
@@ -335,21 +334,17 @@ class S3Client(SyncClient):
335
334
  Metadata={self.__class__.symlink_target_metaname: target},
336
335
  )
337
336
 
338
- def glob( # type: ignore[override]
339
- self, path: str, pattern: str, _return_panpath: bool = False
340
- ) -> Iterator[Union[str, "PanPath"]]:
337
+ def glob(self, path: str, pattern: str) -> Iterator[str]:
341
338
  """Glob for files matching pattern.
342
339
 
343
340
  Args:
344
341
  path: Base S3 path
345
342
  pattern: Glob pattern (e.g., "*.txt", "**/*.py")
346
- _return_panpath: If True, return PanPath objects; if False, return strings
347
343
 
348
344
  Returns:
349
345
  List of matching paths (as PanPath objects or strings)
350
346
  """
351
347
  from fnmatch import fnmatch
352
- from panpath.base import PanPath
353
348
 
354
349
  bucket, prefix = self.__class__._parse_path(path)
355
350
 
@@ -371,10 +366,7 @@ class S3Client(SyncClient):
371
366
  key = obj["Key"]
372
367
  if fnmatch(key, f"*{file_pattern}"):
373
368
  path_str = f"{self.prefix[0]}://{bucket}/{key}"
374
- if _return_panpath:
375
- yield PanPath(path_str)
376
- else: # pragma: no cover
377
- yield path_str
369
+ yield path_str
378
370
  else:
379
371
  # Non-recursive - list objects with delimiter
380
372
  prefix_with_slash = f"{prefix}/" if prefix and not prefix.endswith("/") else prefix
@@ -386,12 +378,9 @@ class S3Client(SyncClient):
386
378
  key = obj["Key"]
387
379
  if fnmatch(key, f"{prefix_with_slash}{pattern}"):
388
380
  path_str = f"{self.prefix[0]}://{bucket}/{key}"
389
- if _return_panpath:
390
- yield PanPath(path_str)
391
- else: # pragma: no cover
392
- yield path_str
381
+ yield path_str
393
382
 
394
- def walk( # type: ignore[override]
383
+ def walk(
395
384
  self, path: str
396
385
  ) -> Iterator[tuple[str, list[str], list[str]]]:
397
386
  """Walk directory tree.
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "panpath"
7
- version = "0.4.1"
7
+ version = "0.4.3"
8
8
  description = "Universal sync/async local/cloud path library with pathlib-compatible interface"
9
9
  authors = ["panpath contributors"]
10
10
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes