diff --git a/sdks/python/apache_beam/options/pipeline_options.py b/sdks/python/apache_beam/options/pipeline_options.py index 2c2748400a2a..bea4d55e1746 100644 --- a/sdks/python/apache_beam/options/pipeline_options.py +++ b/sdks/python/apache_beam/options/pipeline_options.py @@ -55,10 +55,10 @@ _LOGGER = logging.getLogger(__name__) -# Map the boolean option with the flag_name for the flags that have a -# destination(dest) different from the flag name and the -# default value is None in parser.add_argument(). -_FLAGS_WITH_DIFFERENT_DEST = {'use_public_ips': 'no_use_public_ips'} +# Map defined with option names to flag names for boolean options +# that have a destination(dest) in parser.add_argument() different +# from the flag name and whose default value is `None`. +_FLAG_THAT_SETS_FALSE_VALUE = {'use_public_ips': 'no_use_public_ips'} def _static_value_provider_of(value_type): @@ -259,12 +259,12 @@ def from_dictionary(cls, options): if isinstance(v, bool): if v: flags.append('--%s' % k) - elif k in _FLAGS_WITH_DIFFERENT_DEST: + elif k in _FLAG_THAT_SETS_FALSE_VALUE: # Capture overriding flags, which have a different dest # from the flag name defined in the parser.add_argument # Eg: no_use_public_ips, which has the dest=use_public_ips # different from flag name - flag_that_disables_the_option = (_FLAGS_WITH_DIFFERENT_DEST[k]) + flag_that_disables_the_option = (_FLAG_THAT_SETS_FALSE_VALUE[k]) flags.append('--%s' % flag_that_disables_the_option) elif isinstance(v, list): for i in v: diff --git a/sdks/python/apache_beam/options/pipeline_options_test.py b/sdks/python/apache_beam/options/pipeline_options_test.py index d49ecec66702..3195f3594fe0 100644 --- a/sdks/python/apache_beam/options/pipeline_options_test.py +++ b/sdks/python/apache_beam/options/pipeline_options_test.py @@ -687,15 +687,15 @@ def test_options_store_false_with_different_dest(self): "to the user. Please specify the dest as the " "flag_name instead.")) from apache_beam.options.pipeline_options import ( - _FLAGS_WITH_DIFFERENT_DEST) + _FLAG_THAT_SETS_FALSE_VALUE) self.assertDictEqual( - _FLAGS_WITH_DIFFERENT_DEST, + _FLAG_THAT_SETS_FALSE_VALUE, options_to_flags, "If you are adding a new boolean flag with default=None," " with different dest/option_name from the flag name, please add " "the dest and the flag name to the map " - "_FLAGS_WITH_DIFFERENT_DEST in PipelineOptions.py") + "_FLAG_THAT_SETS_FALSE_VALUE in PipelineOptions.py") if __name__ == '__main__':