Skip to content

Commit ba84dcf

Browse files
committed
make pkutil path arg less ambiguous
closes #90149
1 parent f6da790 commit ba84dcf

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.3.4
3+
rev: v0.4.4
44
hooks:
55
- id: ruff
66
name: Run Ruff on Lib/test/
@@ -20,7 +20,7 @@ repos:
2020
language_version: python3.12
2121

2222
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: v4.5.0
23+
rev: v4.6.0
2424
hooks:
2525
- id: check-case-conflict
2626
- id: check-merge-conflict

Doc/library/pkgutil.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ support.
127127
Yields :class:`ModuleInfo` for all submodules on *path*, or, if
128128
*path* is ``None``, all top-level modules on :data:`sys.path`.
129129

130-
*path* should be either ``None`` or a list of paths to look for modules in.
130+
*path* should be either ``None`` or a list of paths (List[str]) to search
131+
for modules.
131132

132133
*prefix* is a string to output on the front of every module name on output.
133134

@@ -148,7 +149,8 @@ support.
148149
Yields :class:`ModuleInfo` for all modules recursively on
149150
*path*, or, if *path* is ``None``, all accessible modules.
150151

151-
*path* should be either ``None`` or a list of paths to look for modules in.
152+
*path* should be either ``None`` or a list of paths (List[str]) to search
153+
for modules.
152154

153155
*prefix* is a string to output on the front of every module name on output.
154156

Lib/pkgutil.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def walk_packages(path=None, prefix='', onerror=None):
4040
"""Yields ModuleInfo for all modules recursively
4141
on path, or, if path is None, all accessible modules.
4242
43-
'path' should be either None or a list of paths to look for
44-
modules in.
43+
'path' should be either None or a list of paths (List[str]) to search
44+
for modules.
4545
4646
'prefix' is a string to output on the front of every module name
4747
on output.
@@ -97,17 +97,17 @@ def iter_modules(path=None, prefix=''):
9797
"""Yields ModuleInfo for all submodules on path,
9898
or, if path is None, all top-level modules on sys.path.
9999
100-
'path' should be either None or a list of paths to look for
101-
modules in.
100+
'path' should be either None or a list of paths (List[str]) to search
101+
for modules.
102102
103103
'prefix' is a string to output on the front of every module name
104104
on output.
105105
"""
106106
if path is None:
107107
importers = iter_importers()
108108
elif isinstance(path, str):
109-
raise ValueError("path must be None or list of paths to look for "
110-
"modules in")
109+
raise ValueError("path must be None or a list of paths (List[str]) to"
110+
" search for modules")
111111
else:
112112
importers = map(get_importer, path)
113113

Lib/test/test_pkgutil.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ def test_issue44061_iter_modules(self):
130130
del sys.path[0]
131131
sys.modules.pop(pkg, None)
132132

133-
# assert path must be None or list of paths
134-
expected_msg = "path must be None or list of paths to look for modules in"
133+
# assert path must be None or a list of paths (List[str])
134+
expected_msg = "path must be None or list of a paths (List[str]) " \
135+
"to search for modules"
135136
with self.assertRaisesRegex(ValueError, expected_msg):
136137
list(pkgutil.iter_modules("invalid_path"))
137138

0 commit comments

Comments
 (0)