Skip to content

Commit c8d819f

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 5f1fc97 commit c8d819f

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
@@ -36,6 +36,7 @@
3636
from pip._internal.models.direct_url import DIRECT_URL_METADATA_NAME, DirectUrl
3737
from pip._internal.utils.deprecation import deprecated
3838
from pip._internal.utils.filesystem import adjacent_tmp_file, replace
39+
from pip._internal.utils.messages import oxford_comma_join
3940
from pip._internal.utils.misc import captured_stdout, ensure_dir, hash_file
4041
from pip._internal.utils.temp_dir import TempDirectory
4142
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
@@ -418,15 +419,18 @@ def _report_file_owner_conflicts(
418419
# There are no other owners for this file.
419420
continue
420421
destfile = os.path.join(lib_dir, basedir, f)
421-
for owner in files_from_other_owners[partial_src]:
422-
deprecated(
423-
reason=('Overwriting or removing {} for {} '
424-
'which is also owned by {}'.format(
425-
destfile, name, owner)),
426-
replacement=None,
427-
gone_in="21.0",
428-
issue="4625",
429-
)
422+
deprecated(
423+
reason=(
424+
'Overwriting or removing {} for {} '
425+
'which is also owned by {}'.format(
426+
destfile, name,
427+
oxford_comma_join(
428+
sorted(files_from_other_owners[partial_src])),
429+
)),
430+
replacement=None,
431+
gone_in="21.0",
432+
issue=4625,
433+
)
430434

431435

432436
def install_unpacked_wheel(

tests/functional/test_install_wheel.py

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

755755
msg = 'Overwriting or removing {} for {} which is also owned by {}'.format(
756-
full_path, 'wheel3', 'wheel1 1.0')
757-
assert msg in result.stderr
758-
759-
msg = 'Overwriting or removing {} for {} which is also owned by {}'.format(
760-
full_path, 'wheel3', 'wheel2 2.0')
756+
full_path, 'wheel3', 'wheel1 1.0 and wheel2 2.0')
761757
assert msg in result.stderr

0 commit comments

Comments
 (0)