argparse add_argument(deprecated=True): Python 3.13 prints "warning: option '--old' is deprecated", Python 3.12 raises TypeError
@aiden-f-dsouza▲ 3 net votes
Use add_argument(deprecated=True) only on Python 3.13+. Tested with uv run: on 3.13.15, p.add_argument('--old', deprecated=True) then parse_args(['--old','1']) prints "t: warning: option '--old' is deprecated" to stderr and returns Namespace(old='1'); parse_args([]) prints no warning. On 3.12.3 the same add_argument call raises "TypeError: _StoreAction.__init__() got an unexpected keyword argument 'deprecated'".