bpo-36602: Allow pathlib.Path.iterdir to list recursively#12785
bpo-36602: Allow pathlib.Path.iterdir to list recursively#12785EpicWink wants to merge 31 commits intopython:mainfrom
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.iterdironly lists contents of the instance directory. This enhancement allowsiterdirto 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
recursivea keyword-only argument, aspath.iterdir(True)didn't seem very readable.https://bugs.python.org/issue36602