Skip to content

Commit cca8cfb

Browse files
committed
emit a single warning for overwriting files
Rather than emitting a separate warning for each owner, produce one warning with all of the other owner names in the message. Signed-off-by: Doug Hellmann <[email protected]>
1 parent 23f152e commit cca8cfb

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/pip/_internal/operations/install/wheel.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from pip._internal.models.direct_url import DIRECT_URL_METADATA_NAME, DirectUrl
3131
from pip._internal.utils.deprecation import deprecated
3232
from pip._internal.utils.filesystem import adjacent_tmp_file, replace
33+
from pip._internal.utils.messages import oxford_comma_join
3334
from pip._internal.utils.misc import captured_stdout, ensure_dir, hash_file
3435
from pip._internal.utils.temp_dir import TempDirectory
3536
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
@@ -407,15 +408,18 @@ def _report_file_owner_conflicts(lib_dir, name, source_dir, info_dir):
407408
# There are no other owners for this file.
408409
continue
409410
destfile = os.path.join(lib_dir, basedir, f)
410-
for owner in files_from_other_owners[partial_src]:
411-
deprecated(
412-
reason=('Overwriting or removing {} for {} '
413-
'which is also owned by {}'.format(
414-
destfile, name, owner)),
415-
replacement=None,
416-
gone_in="21.0",
417-
issue="4625",
418-
)
411+
deprecated(
412+
reason=(
413+
'Overwriting or removing {} for {} '
414+
'which is also owned by {}'.format(
415+
destfile, name,
416+
oxford_comma_join(
417+
sorted(files_from_other_owners[partial_src])),
418+
)),
419+
replacement=None,
420+
gone_in="21.0",
421+
issue=4625,
422+
)
419423

420424

421425
def install_unpacked_wheel(

tests/functional/test_install_wheel.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,5 @@ def test_report_file_owner_conflicts_multiple(script, tmpdir):
756756
assert msg in result.stderr
757757

758758
msg = 'Overwriting or removing {} for {} which is also owned by {}'.format(
759-
full_path, 'wheel3', 'wheel1 1.0')
760-
assert msg in result.stderr
761-
762-
msg = 'Overwriting or removing {} for {} which is also owned by {}'.format(
763-
full_path, 'wheel3', 'wheel2 2.0')
759+
full_path, 'wheel3', 'wheel1 1.0 and wheel2 2.0')
764760
assert msg in result.stderr

0 commit comments

Comments
 (0)