Move fileinput into argparse and/or deprecate/remove it

So I’ve read through PEP 594 recently and my eyes got caught by these lines:

fileinput
[…]. The same functionality can be implemented with the argparse module.

Several core developers expressed their interest to keep the module in the standard library, as it is handy for quick scripts.
- PEP 594 - Modules to keep - fileinput

Now my idea would be to implement it with the argparse module and to put it into argparse and update fileinput to use the argparse.ArgumentParser for which it will add a few optional parameters[1] to fileinput.input/fileinput.FileInput.
This should not add any new required parameters or changes to the return values, to make transitioning from fileinput to argparse.fileinput[2] as easy as possible. It would also decrease the total count of std cli modules Python has[3] and would keep the handiness for quick scripts while also adding useful features of the argparse.ArgumentParser.

Example:

import argparse.fileinput as fileinput

files = fileinput.input(
    # These are optional!
    description="Takes files and does something",
    prog="DoSomething"  # <- Default should be None I propose
)
# ... some code

Example output:

$: python example.py -h
usage: DoSomething [-h] [FILES ...]

Takes files and does something.

positional arguments:
 FILES          a file 
[...]

How exactly it should be implemented can, of course, be discussed here, or even if it should because PEP 594 is a bit old, so the Several core developers expressed their interest to keep the module [...], as it is handy for quick scripts. part might no longer be true, but then it can be reconsidered to deprecate and remove fileinput.

I would be willing to implement these changes but first I want some feedback if it even makes sense and how fileinput could be improved further without changing the handiness of it[4]


  1. like description, prog, etc. ↩︎

  2. or something like this ↩︎

  3. I think that fileinput does not contain enough functionality for it to be its own module ↩︎

  4. for example, something I didn’t mention, adding typehints ↩︎