How to run pip in non-interactive mode?
Solution 1:
There is a --yes option specifically for the uninstall command. Calling
pip uninstall --yes <some-package>
uninstalls the package without asking for confirmation.
For installing, piping in the yes command still seems to be the way to go.
Another approach that might be overkill depending on your use case is using a dedicated tool. This is definitely the way to go, if one struggles with automatic installation and configuration on a regular basis. As an example: SaltStacks state system has tons of ways to automate interaction with pip. This is not only for orchestrating server farms, but can be used locally as well by running salt-call directly. See the introduction about running salt masterless.
Solution 2:
Even if it's not documented, with recent versions of setuptools, you can do
pip install --noinput ...
… that will crash instead of hanging on a prompt.
Solution 3:
I'm far from a python/pip expert, but I have used it for various purposes for several years and have yet to encounter a straight forward use of pip install that is interactive. It does have extensive options for less straight forward case (alternate package indices, caching, dev mode, etc,). If you have a specific install case that requires some interaction, my guess is you could automate it by providing the correct combination of specialized options, documented here.
Uninstall is the case I'm much more used to requiring interaction (includes an explicit confirmation to remove modules), and it does in fact support the standard --yes flag you refer to in the question.