The snippet below does behave differently with the PyPI version than it does with any of the built-in versions from Python 2.7+.
from __future__ import print_function
import argparse
parser = argparse.ArgumentParser()
group = parser.add_argument_group('Source arguments')
# Add mutually exclusive group to the argument group.
# The problem only appears in that combination. When using
# a mutually exclusive group without an argument group, then
# the code works consistently across all argparse versions.
oneof = group.add_mutually_exclusive_group(required=True)
oneof.add_argument('--option1')
oneof.add_argument('--option2')
print(parser.parse_args())
Test output from the various Python versions (all on Windows)
Python 2.7 with Pypi package
Inside a virtualenv
Tried 1.1, 1.3 and 1.4 all with the same result
Note the absence of the validation output, the arguments are parsed
c:\python27\python .\parse_test.py
usage: parse_test.py [-h] (--option1 OPTION1 | --option2 OPTION2)
parse_test.py: error: one of the arguments --option1 --option2 is required
Python 3.4
C:\Python34\python .\parse_test.py
usage: parse_test.py [-h] (--option1 OPTION1 | --option2 OPTION2)
parse_test.py: error: one of the arguments --option1 --option2 is required
Python 2.5
C:\Python35\python .\parse_test.py
usage: parse_test.py [-h] (--option1 OPTION1 | --option2 OPTION2)
parse_test.py: error: one of the arguments --option1 --option2 is required
The snippet below does behave differently with the PyPI version than it does with any of the built-in versions from Python 2.7+.
Test output from the various Python versions (all on Windows)
Python 2.7 with Pypi package
Python 2.7
Python 3.4
Python 2.5