Support passing multiple packages to "--exclude" option
This pull request serves as a proof of concept. The provided code represents the minimal implementation required to achieve the intended functionality. I have tested it using the list command as follows: python -m pip list --exclude "argcomplete cffi".
The main proposal is to allow passing multiple package names with the --exclude option, rather than requiring multiple uses of the same option. Alternatively, we could consider introducing a new option for this purpose.
I currently do not have enough expertise with optparse to offer a more refined implementation. If this proposal is accepted, I will commit to enhancing the implementation in the future.
I do not see any real benefit in this - as you note, you can already do python -m pip list --exclude argcomplete --exclude cffi. Why do we need two ways to do this?
As-is, this PR breaks backwards compatibility with any invocation that passes multiple instances of --exclude. If I run pip list --exclude six --exclude virtualenv (or use special shell syntax to do that for me), only virtualenv will be excluded.
$ pip list --exclude={"six", "virtualenv"}
Package Version Editable project location
-------------------- ----------- --------------------------
attrs 24.3.0
[snipped...]
rich 13.9.4
scripttest 1.3
setuptools 75.6.0
six 1.17.0 # <--- this should NOT be here
tomli_w 1.1.0
Werkzeug 3.1.3
wheel 0.45.1
wmctrl 0.5
In addition, I agree with Paul that this isn't an area where we need two ways to do the same thing. Thank you for your interest in improving pip, but we are not going to accept this PR.