-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-36602: Allow pathlib.Path.iterdir to list recursively #12785
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
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
a40cf6b
to
55b10f9
Compare
55b10f9
to
8125ca9
Compare
Thanks for making the requested changes! : please review the changes made to this pull request. |
#13153 has implemented the |
f462f48
to
95d4c49
Compare
1f580aa
to
4bb3b29
Compare
The introduction of PS: helper function: def iterdir_recursive(path: pathlib.Path) -> typing.Generator[pathlib.Path, None, None]:
for child in path.iterdir():
if child.is_dir():
yield from iterdir_recursive(child)
else:
yield child |
Currently,
pathlib.Path.iterdir
only lists contents of the instance directory. This enhancement allowsiterdir
to recurse into subdirectories.The issue references two decisions to be made. I have initially chosen to not yield the contained directories themselves, and I have initially chosen to not resolve paths before checking if they're a directory to be recursed into. Don't hesitate to give criticism on these choices.
In addition, I've decided to make
recursive
a keyword-only argument, aspath.iterdir(True)
didn't seem very readable.https://bugs.python.org/issue36602