summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2024-05-09 11:46:45 (GMT)
committerGitHub <noreply@github.com>2024-05-09 11:46:45 (GMT)
commitda090f1658e72485b201507653f6d673f3e39c86 (patch)
tree82c2c4b0450a4fb9c4343574fe49242774e9a264 /Lib/argparse.py
parentc68acb1384a51eb745f572687eaf677371b9e765 (diff)
downloadcpython-da090f1658e72485b201507653f6d673f3e39c86.zip
cpython-da090f1658e72485b201507653f6d673f3e39c86.tar.gz
cpython-da090f1658e72485b201507653f6d673f3e39c86.tar.bz2
gh-118805: Remove type, choices, metavar params of `BooleanOptionalAction` (#118806)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py28
1 files changed, 0 insertions, 28 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 55bf8cd..cdd29d3 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -831,19 +831,13 @@ class Action(_AttributeHolder):
raise NotImplementedError(_('.__call__() not defined'))
-# FIXME: remove together with `BooleanOptionalAction` deprecated arguments.
-_deprecated_default = object()
-
class BooleanOptionalAction(Action):
def __init__(self,
option_strings,
dest,
default=None,
- type=_deprecated_default,
- choices=_deprecated_default,
required=False,
help=None,
- metavar=_deprecated_default,
deprecated=False):
_option_strings = []
@@ -854,35 +848,13 @@ class BooleanOptionalAction(Action):
option_string = '--no-' + option_string[2:]
_option_strings.append(option_string)
- # We need `_deprecated` special value to ban explicit arguments that
- # match default value. Like:
- # parser.add_argument('-f', action=BooleanOptionalAction, type=int)
- for field_name in ('type', 'choices', 'metavar'):
- if locals()[field_name] is not _deprecated_default:
- import warnings
- warnings._deprecated(
- field_name,
- "{name!r} is deprecated as of Python 3.12 and will be "
- "removed in Python {remove}.",
- remove=(3, 14))
-
- if type is _deprecated_default:
- type = None
- if choices is _deprecated_default:
- choices = None
- if metavar is _deprecated_default:
- metavar = None
-
super().__init__(
option_strings=_option_strings,
dest=dest,
nargs=0,
default=default,
- type=type,
- choices=choices,
required=required,
help=help,
- metavar=metavar,
deprecated=deprecated)