Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

28-fix-pathlib-Path-glob #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions d8s_python/python_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,12 @@ def python_copy_shallow(python_object: Any) -> Any:
# @decorators.map_first_arg
def python_file_names(path: str, *, exclude_tests: bool = False) -> List[str]: # noqa: CCR001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type hint for the return type of this function should be updated. Previously, this function returned a list. Now, as you can see here, it returns a generator (because this is what the pathlib.Path.glob function returns). Does that make sense?

Suggested change
def python_file_names(path: str, *, exclude_tests: bool = False) -> List[str]: # noqa: CCR001
def python_file_names(path: str, *, exclude_tests: bool = False) -> Iterator[str]: # noqa: CCR001

"""Find all python files in the given directory."""
from d8s_file_system import directory_file_names_matching
# from d8s_file_system import directory_file_names_matching
#
# files = directory_file_names_matching(path, '*.py')
Comment on lines +253 to +255
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove these lines as they are no longer needed:

Suggested change
# from d8s_file_system import directory_file_names_matching
#
# files = directory_file_names_matching(path, '*.py')

from pathlib import Path

files = directory_file_names_matching(path, '*.py')
files = Path(path).glob('*.py')

if not exclude_tests:
return files
Expand Down