[Python-ideas] Argparse argument deprecation

Tarek Ziadé tarek at ziade.org
Wed Aug 9 03:56:20 EDT 2017


I don't think there's any helper to deprecate an argument in argparse

Let's say you have a --foo option in your CLI and want to deprecate it
in the next release before you completely remove it later.

My first though on how to do this by adding a new "deprecated" option to

"deprecated" would be a callable that is called after the argument has
been parsed by argparse, 
so the developer can decide if they want to issue a deprecation warning,
use the parsed value or override it etc.

Another interesting approach suggest by Doug Hellman, which I like as
much, is a set of higher level options that
provide a deprecation workflow for arguments, see


What do you think?



Tarek Ziadé | coding: https://ziade.org | running: https://foule.es |
twitter: @tarek_ziade

More information about the Python-ideas mailing list