Only pass exclude-deprecated when True
The '--exclude-deprecated' parameter should only be passed to
oslo.config to parse when it is True.
The final generated sphinx syntax is[1] where [--exclude-deprecated]
doesn't require True/False value and only should be passed when True.
The change introducing this[2] causes parsing issue in oslo.config[3]
while checking <bool>.startswith (we pass True/False value) and even
after that while calling argparse[4] with following error[5].
[1] usage: sphinx-build [-h] [--config-dir DIR] [--config-file PATH] [--exclude-deprecated] [--format FORMAT] [--namespace NAMESPACE]
[--noexclude-deprecated] [--output-file OUTPUT_FILE]
[2] https://review.opendev.org/c/openstack/oslo.policy/+/830514
[3] https://opendev.org/openstack/oslo.config/src/branch/master/oslo_config/cfg.py#L2937
[4] https://opendev.org/openstack/oslo.config/src/branch/master/oslo_config/cfg.py#L2960
[5] > /usr/lib/python3.8/argparse.py(1781)parse_args()
-> if argv:
(Pdb)
> /usr/lib/python3.8/argparse.py(1782)parse_args()
-> msg = _('unrecognized arguments: %s')
(Pdb)
> /usr/lib/python3.8/argparse.py(1783)parse_args()
-> self.error(msg % ' '.join(argv))
(Pdb)
TypeError: sequence item 0: expected str instance, bool found
> /usr/lib/python3.8/argparse.py(1783)parse_args()
-> self.error(msg % ' '.join(argv))
Handler <function generate_sample at 0x7fc0d6697d30> for event 'builder-inited' threw an exception (exception: sequence item 0: expected str instance, bool found)
Closes-Bug: #1970725
Change-Id: I95745b8d1cbdb6a7cf442d431a998b7e3ff600e4
This commit is contained in:
@@ -85,10 +85,12 @@ def _generate_sample(app, policy_file, base_name, exclude_deprecated):
|
||||
# in their documented modules. It's not allowed to register a cli arg after
|
||||
# the args have been parsed once.
|
||||
conf = cfg.ConfigOpts()
|
||||
arguments = ['--config-file', config_path,
|
||||
'--output-file', out_file]
|
||||
if exclude_deprecated:
|
||||
arguments += ['--exclude-deprecated']
|
||||
generator.generate_sample(
|
||||
args=['--config-file', config_path,
|
||||
'--output-file', out_file,
|
||||
'--exclude-deprecated', exclude_deprecated],
|
||||
args=arguments,
|
||||
conf=conf)
|
||||
|
||||
|
||||
|
||||
@@ -34,8 +34,7 @@ class SingleSampleGenerationTest(base.BaseTestCase):
|
||||
|
||||
sample.assert_called_once_with(args=[
|
||||
'--config-file', '/opt/nova/nova.conf',
|
||||
'--output-file', '/opt/nova/nova.policy.yaml.sample',
|
||||
'--exclude-deprecated', False],
|
||||
'--output-file', '/opt/nova/nova.policy.yaml.sample'],
|
||||
conf=mock.ANY)
|
||||
|
||||
@mock.patch('os.path.isdir')
|
||||
@@ -55,7 +54,7 @@ class SingleSampleGenerationTest(base.BaseTestCase):
|
||||
sample.assert_called_once_with(args=[
|
||||
'--config-file', '/opt/nova/nova.conf',
|
||||
'--output-file', '/opt/nova/sample.policy.yaml',
|
||||
'--exclude-deprecated', True],
|
||||
'--exclude-deprecated'],
|
||||
conf=mock.ANY)
|
||||
|
||||
@mock.patch('os.path.isdir')
|
||||
@@ -78,11 +77,9 @@ class SingleSampleGenerationTest(base.BaseTestCase):
|
||||
sample.assert_has_calls([
|
||||
mock.call(args=[
|
||||
'--config-file', '/opt/nova/nova.conf',
|
||||
'--output-file', '/opt/nova/nova.policy.yaml.sample',
|
||||
'--exclude-deprecated', False],
|
||||
'--output-file', '/opt/nova/nova.policy.yaml.sample'],
|
||||
conf=mock.ANY),
|
||||
mock.call(args=[
|
||||
'--config-file', '/opt/nova/placement.conf',
|
||||
'--output-file', '/opt/nova/placement.policy.yaml.sample',
|
||||
'--exclude-deprecated', False],
|
||||
'--output-file', '/opt/nova/placement.policy.yaml.sample'],
|
||||
conf=mock.ANY)])
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed passing ``--exclude-deprecated`` boolean value to
|
||||
sphinx-build command. Now ``--exclude-deprecated`` is only
|
||||
passed when it is True without bool True/False value.
|
||||
Reference in New Issue
Block a user