If input and stdin parameters are passed as keyword arguments to subprocess.run, an exception is thrown even if input and stdin are both None.
The exception is ValueError: stdin and input arguments may not both be used.
I attach a minimal working example of the bug

subprocess.run('ls', input=b'', stdin=None) # this is ok
kwargs = {'input': b'', 'stdin': None}
subprocess.run('ls', **kwargs) # this throws exception
The two calls should have the same behaviour, but one throws exception and the other doesn't. I think the exception shouldn't be thrown, because stdin is None.

The actual code receives input by name, but stdin is received in **kwargs. The test is just:
if input is not None:
if 'stdin' in kwargs:
raise ValueError(...)
kwargs['stdin'] = PIPE
Perhaps just change `if 'stdin' in kwargs:` to:
if kwargs.get('stdin') is not None:
so it obeys the documented API (that says stdin defaults to None, and therefore passing stdin=None explicitly should be equivalent to not passing it at all)?

> and I got the same ValueError as for passing using kwargs. Where did you get the idea subprocess.run('ls', input=b'', stdin=None) worked?
Sorry, the example was wrong. Both calls have the same behaviour.
> so it obeys the documented API (that says stdin defaults to None, and therefore passing stdin=None explicitly should be equivalent to not passing it at all)?
The actual problem is this. The fix you propose works for me.