gh-144835: Added missing explanations for some parameters in glob and iglob.#144836
gh-144835: Added missing explanations for some parameters in glob and iglob.#144836facundobatista wants to merge 4 commits intopython:mainfrom
Conversation
| If root_dir is not None, it should be a path-like object specifying the | ||
| root directory for searching. It has the same effect as changing the | ||
| current directory before calling it. If pathname is relative, the | ||
| result will contain paths relative to root_dir. | ||
|
|
||
| If dir_fd is not None, it should be a file descriptor referring to a | ||
| directory, and paths will then be relative to that directory. | ||
|
|
||
| If `include_hidden` is true, the patterns '*', '?', '**' will match hidden | ||
| directories. |
There was a problem hiding this comment.
We should be consistent with backticks for args, either use for all or none.
I do see that PyCharm shows them in italics, so there is a benefit to using them as it makes the text more readable:
| If root_dir is not None, it should be a path-like object specifying the | |
| root directory for searching. It has the same effect as changing the | |
| current directory before calling it. If pathname is relative, the | |
| result will contain paths relative to root_dir. | |
| If dir_fd is not None, it should be a file descriptor referring to a | |
| directory, and paths will then be relative to that directory. | |
| If `include_hidden` is true, the patterns '*', '?', '**' will match hidden | |
| directories. | |
| If `root_dir` is not None, it should be a path-like object specifying the | |
| root directory for searching. It has the same effect as changing the | |
| current directory before calling it. If `pathname` is relative, the | |
| result will contain paths relative to root_dir. | |
| If `dir_fd` is not None, it should be a file descriptor referring to a | |
| directory, and paths will then be relative to that directory. | |
| If `include_hidden` is true, the patterns '*', '?', '**' will match hidden | |
| directories. |
|
|
||
| def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False, | ||
| include_hidden=False): | ||
| """Return an iterator which yields the paths matching a pathname pattern. |
There was a problem hiding this comment.
| """Return an iterator which yields the paths matching a `pathname` pattern. |
| If root_dir is not None, it should be a path-like object specifying the | ||
| root directory for searching. It has the same effect as changing the | ||
| current directory before calling it. If pathname is relative, the | ||
| result will contain paths relative to root_dir. | ||
|
|
||
| If dir_fd is not None, it should be a file descriptor referring to a | ||
| directory, and paths will then be relative to that directory. |
There was a problem hiding this comment.
| If root_dir is not None, it should be a path-like object specifying the | |
| root directory for searching. It has the same effect as changing the | |
| current directory before calling it. If pathname is relative, the | |
| result will contain paths relative to root_dir. | |
| If dir_fd is not None, it should be a file descriptor referring to a | |
| directory, and paths will then be relative to that directory. | |
| If `root_dir` is not None, it should be a path-like object specifying the | |
| root directory for searching. It has the same effect as changing the | |
| current directory before calling it. If `pathname` is relative, the | |
| result will contain paths relative to root_dir. | |
| If `dir_fd` is not None, it should be a file descriptor referring to a | |
| directory, and paths will then be relative to that directory. |
There was a problem hiding this comment.
I'm wary of "It has the same effect as changing the current directory before calling it" phrasing as we don't want anyone to think that the process wide global cwd is changed by these API calls. I think it may be better to state what the default behavior is when not specified or None. ie "if not specified or None, the search will be conducted from the processes current working directory and returned paths will be relative to that" (Q: is that accurate?)
terryjreedy
left a comment
There was a problem hiding this comment.
I agree with Hugo's suggestions, and yes, backport.
|
When you're done making the requested changes, leave the comment: |
I took the explanations for the missing parameters from the documentation itself (slightly edited for brevity) for the cases of
root_diranddir_fdin bothglobandiglob.For the case of
iglob'sinclude_hidden, I just copied it fromglob.