Skip to content

Commit ce4b760

Browse files
committed
Remove support for returning the directories created in mkpath, unused.
Closes pypa#306
1 parent bc1aa6f commit ce4b760

File tree

2 files changed

+1
-18
lines changed

2 files changed

+1
-18
lines changed

distutils/dir_util.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,23 @@ def wrapper(path, *args, **kwargs):
4444

4545
@functools.singledispatch
4646
@wrapper
47-
def mkpath(name: pathlib.Path, mode=0o777, verbose=True, dry_run=False):
47+
def mkpath(name: pathlib.Path, mode=0o777, verbose=True, dry_run=False) -> None:
4848
"""Create a directory and any missing ancestor directories.
4949
5050
If the directory already exists (or if 'name' is the empty string, which
5151
means the current directory, which of course exists), then do nothing.
5252
Raise DistutilsFileError if unable to create some directory along the way
5353
(eg. some sub-path exists, but is a file rather than a directory).
5454
If 'verbose' is true, log the directory created.
55-
Return the list of directories actually created.
5655
"""
5756
if verbose and not name.is_dir():
5857
log.info("creating %s", name)
5958

60-
ancestry = itertools.chain((name,), name.parents)
61-
missing = list(path for path in ancestry if not path.is_dir())
62-
6359
try:
6460
dry_run or name.mkdir(mode=mode, parents=True, exist_ok=True)
6561
except OSError as exc:
6662
raise DistutilsFileError(f"could not create '{name}': {exc.args[-1]}")
6763

68-
return list(map(str, missing))
69-
7064

7165
@mkpath.register
7266
def _(name: str, *args, **kwargs):

distutils/tests/test_dir_util.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ def test_mkpath_with_custom_mode(self):
5252
mkpath(self.target2, 0o555)
5353
assert stat.S_IMODE(os.stat(self.target2).st_mode) == 0o555 & ~umask
5454

55-
def test_mkpath_returns_as_described(self, tmp_path):
56-
"""
57-
Per the docstring, mkpath should return the list of directories created.
58-
59-
pypa/distutils#305 revealed that the return value is always the empty
60-
string and no one complained. Consider removing this expectation.
61-
"""
62-
target = tmp_path / 'foodir'
63-
res = mkpath(target)
64-
assert res == [str(target)]
65-
6655
def test_create_tree_verbosity(self, caplog):
6756
create_tree(self.root_target, ['one', 'two', 'three'], verbose=False)
6857
assert caplog.messages == []

0 commit comments

Comments
 (0)