Skip to content

Commit e0054eb

Browse files
committed
Merge branch 'master' into 3.0.0
2 parents 57ffd7b + 5d2a0e9 commit e0054eb

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
* Added `RawDescriptionCmd2HelpFormatter`, `RawTextCmd2HelpFormatter`, `ArgumentDefaultsCmd2HelpFormatter`,
1111
and `MetavarTypeCmd2HelpFormatter` and they all use `rich-argparse`.
1212

13+
## 2.5.5 (November 13, 2024)
14+
* Bug Fixes
15+
* Fixed type hints for passing a class method to `with_argparser` and `as_subcommand_to`.
16+
* Fixed issue where `set` command was not always printing a settable's current value.
17+
1318
## 2.5.4 (November 6, 2024)
1419
* Bug Fixes
1520
* Fixed `ZeroDivisionError` in `async_alert()` when `shutil.get_terminal_size().columns` is 0.

cmd2/cmd2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,11 +3910,11 @@ def do_set(self, args: argparse.Namespace) -> None:
39103910
# Try to update the settable's value
39113911
try:
39123912
orig_value = settable.get_value()
3913-
new_value = settable.set_value(utils.strip_quotes(args.value))
3913+
settable.set_value(utils.strip_quotes(args.value))
39143914
except Exception as ex:
39153915
self.perror(f"Error setting {args.param}: {ex}")
39163916
else:
3917-
self.poutput(f"{args.param} - was: {orig_value!r}\nnow: {new_value!r}")
3917+
self.poutput(f"{args.param} - was: {orig_value!r}\nnow: {settable.get_value()!r}")
39183918
self.last_result = True
39193919
return
39203920

cmd2/utils.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,14 @@ def get_bool_choices(_) -> list[str]: # type: ignore[no-untyped-def]
176176
self.completer = completer
177177

178178
def get_value(self) -> Any:
179-
"""
180-
Get the value of the settable attribute
181-
:return:
182-
"""
179+
"""Get the value of the settable attribute."""
183180
return getattr(self.settable_obj, self.settable_attrib_name)
184181

185-
def set_value(self, value: Any) -> Any:
182+
def set_value(self, value: Any) -> None:
186183
"""
187-
Set the settable attribute on the specified destination object
188-
:param value: New value to set
189-
:return: New value that the attribute was set to
184+
Set the settable attribute on the specified destination object.
185+
186+
:param value: new value to set
190187
"""
191188
# Run the value through its type function to handle any conversion or validation
192189
new_value = self.val_type(value)
@@ -203,7 +200,6 @@ def set_value(self, value: Any) -> Any:
203200
# Check if we need to call an onchange callback
204201
if orig_value != new_value and self.onchange_cb:
205202
self.onchange_cb(self.name, orig_value, new_value)
206-
return new_value
207203

208204

209205
def is_text_file(file_path: str) -> bool:

0 commit comments

Comments
 (0)