-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
28-fix-pathlib-Path-glob #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, thank you for the pull request (PR) @sachindavra! The change you made is looking good. There are a few other things which need updated, though. I've made a couple of suggestions below. In addition to the changes I suggested, there are two other things we need to change before this PR is complete:
- On this line, we return
files
variable.files
is a generator (because this is what the pathlib.Path.glob function returns). The problem is that this section of the function returns a list. When possible, it is a best practice to always return an item of the same type from a function, so we should update this section of the function to yield file names rather than append them to a list and return the list. - The tests for this PR are failing as you can see here. They are failing because the tests are expecting the function to return a list, but we are now returning a generator. We should update the tests to cast the response from the function to a tuple like:
assert tuple(python_file_names(...)) == ('a.py', 'a_test.py')`
If you have any questions on either of these ^ points or if you would like me to work on them, let me know. Thanks again for the PR!
Fixes #28 .
# from d8s_file_system import directory_file_names_matching | ||
# | ||
# files = directory_file_names_matching(path, '*.py') |
There was a problem hiding this comment.
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:
# from d8s_file_system import directory_file_names_matching | |
# | |
# files = directory_file_names_matching(path, '*.py') |
@@ -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 |
There was a problem hiding this comment.
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?
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 |
Hi @sachindavra : Any progress on this issue? Thanks for creating the PR. I've added some feedback above which I'd like you to review and commit before we merge this. (This PR fixes #28 ) |
No description provided.