Skip to content

Commit 3396da0

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 1ea778c commit 3396da0

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
@@ -416,15 +417,18 @@ def _report_file_owner_conflicts(
416417
# There are no other owners for this file.
417418
continue
418419
destfile = os.path.join(lib_dir, basedir, f)
419-
for owner in files_from_other_owners[partial_src]:
420-
deprecated(
421-
reason=('Overwriting or removing {} for {} '
422-
'which is also owned by {}'.format(
423-
destfile, name, owner)),
424-
replacement=None,
425-
gone_in="21.0",
426-
issue="4625",
427-
)
420+
deprecated(
421+
reason=(
422+
'Overwriting or removing {} for {} '
423+
'which is also owned by {}'.format(
424+
destfile, name,
425+
oxford_comma_join(
426+
sorted(files_from_other_owners[partial_src])),
427+
)),
428+
replacement=None,
429+
gone_in="21.0",
430+
issue=4625,
431+
)
428432

429433

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