sftp.py 549 B

1234567891011121314151617181920212223242526
  1. from __future__ import annotations
  2. import sys
  3. from typing import TYPE_CHECKING
  4. from typing import Any
  5. from typing import Generator
  6. if TYPE_CHECKING:
  7. if sys.version_info >= (3, 11):
  8. from typing import Self
  9. else:
  10. from typing_extensions import Self
  11. from upath import UPath
  12. _unset: Any = object()
  13. class SFTPPath(UPath):
  14. __slots__ = ()
  15. def iterdir(self) -> Generator[Self, None, None]:
  16. if not self.is_dir():
  17. raise NotADirectoryError(str(self))
  18. else:
  19. return super().iterdir()