Description
When using UPath with S3 (via s3fs/fsspec), S3Path.is_file() appears to always return True (even for “directory-like” prefixes). As a result, S3Path.iterdir() treats S3 prefixes as files and raises NotADirectoryError, making it impossible (or unreliable) to list “directories” on S3.
Given that object stores don’t have real directories, checking not is_dir() (instead of is_file()) is a more reliable guard for iterdir().
Steps to reproduce
from upath import UPath
p = UPath("s3://my-bucket/some/prefix/")
print("is_file:", p.is_file()) # True
print("is_dir:", p.is_dir()) # True
print("is_file:", p.is_file()) # False
print("is_dir:", p.is_dir()) # True
Environment
- upath version: 0.3.7
- fsspec version: 2025.12.0
- s3fs version: 2025.12.0
- Python: 3.12