From 83bbc0df4316e8a17b8417d02c80cd0cf5a8568e Mon Sep 17 00:00:00 2001 From: Philippe SERAPHIN Date: Mon, 18 Dec 2023 10:02:11 +0100 Subject: [PATCH] Add choices parameter for IntOpt class Change-Id: Ic9e9a2fd7d1229616387a6a9d61f8a5b8f32829f --- oslo_config/cfg.py | 15 +++++++++++++-- ...rameter_for_IntOpt_class-1b5e42c475c08f08.yaml | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/add_choices_parameter_for_IntOpt_class-1b5e42c475c08f08.yaml diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index 35f0cfb5..dbc6a20d 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -1015,15 +1015,26 @@ class IntOpt(Opt): :param name: the option's name :param min: minimum value the integer can take :param max: maximum value the integer can take + :param choices: Optional sequence of either valid values or tuples of valid + values with descriptions. :param \*\*kwargs: arbitrary keyword arguments passed to :class:`Opt` .. versionchanged:: 1.15 Added *min* and *max* parameters. + + + .. versionchanged:: 9.3.0 + + Added *choices* parameter. """ - def __init__(self, name, min=None, max=None, **kwargs): - super(IntOpt, self).__init__(name, type=types.Integer(min, max), + def __init__(self, name, min=None, max=None, choices=None, **kwargs): + super(IntOpt, self).__init__(name, + type=types.Integer( + min=min, + max=max, + choices=choices), **kwargs) diff --git a/releasenotes/notes/add_choices_parameter_for_IntOpt_class-1b5e42c475c08f08.yaml b/releasenotes/notes/add_choices_parameter_for_IntOpt_class-1b5e42c475c08f08.yaml new file mode 100644 index 00000000..341c6e6a --- /dev/null +++ b/releasenotes/notes/add_choices_parameter_for_IntOpt_class-1b5e42c475c08f08.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add choice parameter for IntOpt class for conformity with types.Integer.