Skip to content

Commit 72f7a72

Browse files
committed
make pkutil path arg less ambiguous
closes #90149
1 parent 9fa206a commit 72f7a72

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

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 = r"path must be None or a list of 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)