Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ class BooleanOptionalAction(Action):
def __init__(self,
option_strings,
dest,
const=None,
default=None,
type=None,
choices=None,
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,14 @@ class TestBooleanOptionalAction(ParserTestCase):
('--no-foo --foo', NS(foo=True)),
]

def test_const(self):
# See bpo-40862
parser = argparse.ArgumentParser()
with self.assertRaises(TypeError) as cm:
parser.add_argument('--foo', const=True, action=argparse.BooleanOptionalAction)

self.assertIn("got an unexpected keyword argument 'const'", str(cm.exception))

class TestBooleanOptionalActionRequired(ParserTestCase):
"""Tests BooleanOptionalAction required"""

Expand Down