Skip to content

gh-144835: Added missing explanations for some parameters in glob and iglob.#144836

Open
facundobatista wants to merge 4 commits intopython:mainfrom
facundobatista:improve-globglob-docstrings
Open

gh-144835: Added missing explanations for some parameters in glob and iglob.#144836
facundobatista wants to merge 4 commits intopython:mainfrom
facundobatista:improve-globglob-docstrings

Conversation

@facundobatista
Copy link
Member

@facundobatista facundobatista commented Feb 15, 2026

I took the explanations for the missing parameters from the documentation itself (slightly edited for brevity) for the cases of root_dir and dir_fd in both glob and iglob.

For the case of iglob's include_hidden, I just copied it from glob.

Comment on lines +57 to +66
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.
Copy link
Member

@hugovk hugovk Feb 15, 2026

Choose a reason for hiding this comment

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

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:

Image
Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"""Return an iterator which yields the paths matching a `pathname` pattern.

Comment on lines +28 to +34
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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Member

Choose a reason for hiding this comment

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

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?)

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

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

I agree with Hugo's suggestions, and yes, backport.

@bedevere-app
Copy link

bedevere-app bot commented Feb 15, 2026

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@terryjreedy terryjreedy added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants