Files
langchain/tests/unit_tests
os1ma 1366d070fc Add path validation to DirectoryLoader (#5327)
# Add path validation to DirectoryLoader

This PR introduces a minor adjustment to the DirectoryLoader by adding
validation for the path argument. Previously, if the provided path
didn't exist or wasn't a directory, DirectoryLoader would return an
empty document list due to the behavior of the `glob` method. This could
potentially cause confusion for users, as they might expect a
file-loading error instead.

So, I've added two validations to the load method of the
DirectoryLoader:

- Raise a FileNotFoundError if the provided path does not exist
- Raise a ValueError if the provided path is not a directory

Due to the relatively small scope of these changes, a new issue was not
created.

## Before submitting

<!-- If you're adding a new integration, please include:

1. a test for the integration - favor unit tests that does not rely on
network access.
2. an example notebook showing its use


See contribution guidelines for more information on how to write tests,
lint
etc:


https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md
-->

## Who can review?

Community members can review the PR once tests pass. Tag
maintainers/contributors who might be interested:

@eyurtsev
2023-05-28 15:31:23 -04:00
..
2023-04-30 11:14:09 -07:00
2023-05-11 15:34:06 -07:00
2023-05-25 13:42:10 -07:00
2023-05-20 08:21:52 -07:00
2023-05-24 10:02:09 -07:00
2023-05-19 15:27:50 -07:00
2022-10-24 14:51:15 -07:00
2023-05-22 16:43:07 -07:00
2022-10-24 14:51:15 -07:00