Skip to content

Commit ea60a80

Browse files
committed
Removed apply_style from Cmd.pwarning().
1 parent 673eec3 commit ea60a80

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
## 2.5.0 (TBD)
22
* Breaking Change
33
* `cmd2` 2.5 supports Python 3.7+ (removed support for Python 3.6)
4+
* Bug Fixes
5+
* Fixed issue where persistent history file was not saved upon SIGTERM and SIGHUP signals.
46
* Enhancements
57
* Removed dependency on `attrs` and replaced with [dataclasses](https://docs.python.org/3/library/dataclasses.html)
68
* add `allow_clipboard` initialization parameter and attribute to disable ability to
79
add output to the operating system clipboard
10+
* Deletions (potentially breaking changes)
11+
* Removed `apply_style` from `Cmd.pwarning()`.
812

913

1014
## 2.4.3 (January 27, 2023)

cmd2/cmd2.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,24 +1223,17 @@ def pwarning(
12231223
msg: Any = '',
12241224
*,
12251225
end: str = '\n',
1226-
apply_style: bool = True,
12271226
paged: bool = False,
12281227
chop: bool = False,
12291228
) -> None:
12301229
"""Wraps perror, but applies ansi.style_warning by default
12311230
12321231
:param msg: object to print
12331232
:param end: string appended after the end of the message, default a newline
1234-
:param apply_style:
1235-
If True, then ansi.style_warning will be applied to the message text. Set to False in cases
1236-
where the message text already has the desired style. Defaults to True.
1237-
1238-
.. deprecated: 2.4.4
1239-
Use :meth:`~cmd2.Cmd.print_to` instead to print to stderr without style applied.
12401233
:param paged: If True, pass the output through the configured pager.
12411234
:param chop: If paged is True, True to truncate long lines or False to wrap long lines.
12421235
"""
1243-
self.print_to(sys.stderr, msg, end=end, style=ansi.style_warning if apply_style else None, paged=paged, chop=chop)
1236+
self.print_to(sys.stderr, msg, end=end, style=ansi.style_warning, paged=paged, chop=chop)
12441237

12451238
def pfailure(
12461239
self,
@@ -2437,7 +2430,7 @@ def sigint_handler(self, signum: int, _: FrameType) -> None:
24372430
if raise_interrupt:
24382431
self._raise_keyboard_interrupt()
24392432

2440-
def sigterm_handler(self, signum: int, _: FrameType) -> None:
2433+
def sigterm_handler(self, signum: int, _: FrameType) -> None: # pragma: no cover
24412434
"""
24422435
Signal handler for SIGTERMs which are sent to politely ask this app to terminate.
24432436
@@ -2449,7 +2442,7 @@ def sigterm_handler(self, signum: int, _: FrameType) -> None:
24492442
# Gracefully exit so the persistent history file will be written.
24502443
sys.exit(self.exit_code)
24512444

2452-
def sighup_handler(self, signum: int, _: FrameType) -> None:
2445+
def sighup_handler(self, signum: int, _: FrameType) -> None: # pragma: no cover
24532446
"""
24542447
Signal handler for SIGHUPs which are sent when the terminal is closed.
24552448

tests/test_cmd2.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,24 +2316,6 @@ def test_perror_no_style(base_app, capsys):
23162316
assert err == msg + end
23172317

23182318

2319-
@with_ansi_style(ansi.AllowStyle.ALWAYS)
2320-
def test_pwarning_style(base_app, capsys):
2321-
msg = 'testing...'
2322-
end = '\n'
2323-
base_app.pwarning(msg)
2324-
out, err = capsys.readouterr()
2325-
assert err == ansi.style_warning(msg) + end
2326-
2327-
2328-
@with_ansi_style(ansi.AllowStyle.ALWAYS)
2329-
def test_pwarning_no_style(base_app, capsys):
2330-
msg = 'testing...'
2331-
end = '\n'
2332-
base_app.pwarning(msg, apply_style=False)
2333-
out, err = capsys.readouterr()
2334-
assert err == msg + end
2335-
2336-
23372319
@with_ansi_style(ansi.AllowStyle.ALWAYS)
23382320
def test_pexcept_style(base_app, capsys):
23392321
msg = Exception('testing...')

0 commit comments

Comments
 (0)