Skip to content

upath: raise FileNotFoundError for a missing path in iterdir() and rmdir() - #605

Open
RavSinghChandan wants to merge 1 commit into
fsspec:mainfrom
RavSinghChandan:iterdir-missing-path
Open

RavSinghChandan wants to merge 1 commit into
fsspec:mainfrom
RavSinghChandan:iterdir-missing-path

Conversation

@RavSinghChandan

Copy link
Copy Markdown

iterdir() and rmdir() on a path that does not exist raise NotADirectoryError. pathlib raises FileNotFoundError, so code that catches it does not work with UPath:

list(UPath("memory:///does-not-exist").iterdir())  # NotADirectoryError

They now raise FileNotFoundError when the path does not exist. A file still raises NotADirectoryError, as #506 intended. A path below a file, such as file.txt/x, now also raises FileNotFoundError, while local pathlib raises NotADirectoryError there.

The new tests in cases.py pass on the backends I could run, including local, memory, S3, FTP and WebDAV; 22 fail without the change. I could not run the Azure, GCS and SFTP suites here (their setup fails without the change too). No test that passed before fails, and pre-commit passes on the changed files.

AI tools: Claude Code (Claude Sonnet 5.5) helped write the code, tests and this description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant