Skip to content

Commit

Permalink
Deleted cmd2.fg and cmd2.bg which were deprecated in 2.3.0. Use cmd2.…
Browse files Browse the repository at this point in the history
…Fg and cmd2.Bg instead.
  • Loading branch information
kmvanbrunt committed Feb 17, 2022
1 parent 9676f8b commit f217861
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 74 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
## 2.3.4 (TBD, 2021)
## 2.4.0 (TBD, 2021)
* Bug Fixes
* Fixed issue in `ansi.async_alert_str()` which would raise `IndexError` if prompt was blank.
* Fixed issue where tab completion was quoting argparse flags in some cases.
* Enhancements
* Added broader exception handling when enabling clipboard functionality via `pyperclip`.
* Added `PassThroughException` to `__init__.py` imports.
* Deletions (potentially breaking changes)
* Deleted `cmd2.fg` and `cmd2.bg` which were deprecated in 2.3.0. Use `cmd2.Fg` and `cmd2.Bg` instead.

## 2.3.3 (November 29, 2021)
* Enhancements
Expand Down
4 changes: 0 additions & 4 deletions cmd2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
RgbBg,
RgbFg,
TextStyle,
bg, # DEPRECATED: Use Bg
fg, # DEPRECATED: Use Fg
style,
)
from .argparse_custom import (
Expand Down Expand Up @@ -81,8 +79,6 @@
'RgbBg',
'RgbFg',
'TextStyle',
'bg', # DEPRECATED: Use Bg
'fg', # DEPRECATED: Use Fg
'style',
# Argparse Exports
'Cmd2ArgumentParser',
Expand Down
67 changes: 0 additions & 67 deletions cmd2/ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,8 +940,6 @@ def __str__(self) -> str:
return self._sequence


# TODO: Remove this PyShadowingNames usage when deprecated fg and bg classes are removed.
# noinspection PyShadowingNames
def style(
value: Any,
*,
Expand Down Expand Up @@ -1086,68 +1084,3 @@ def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_off
# Move the cursor to the beginning of the first prompt line and print the alert
terminal_str += '\r' + alert_msg
return terminal_str


####################################################################################
# The following classes are deprecated.
####################################################################################
# noinspection PyPep8Naming
class fg(FgColor, Enum):
"""Deprecated Enum class for foreground colors. Use Fg instead."""

black = 30
red = 31
green = 32
yellow = 33
blue = 34
magenta = 35
cyan = 36
white = 37
reset = 39
bright_black = 90
bright_red = 91
bright_green = 92
bright_yellow = 93
bright_blue = 94
bright_magenta = 95
bright_cyan = 96
bright_white = 97

def __str__(self) -> str:
"""
Return ANSI color sequence instead of enum name
This is helpful when using an fg in an f-string or format() call
e.g. my_str = f"{fg.blue}hello{fg.reset}"
"""
return f"{CSI}{self.value}m"


# noinspection PyPep8Naming
class bg(BgColor, Enum):
"""Deprecated Enum class for background colors. Use Bg instead."""

black = 40
red = 41
green = 42
yellow = 43
blue = 44
magenta = 45
cyan = 46
white = 47
reset = 49
bright_black = 100
bright_red = 101
bright_green = 102
bright_yellow = 103
bright_blue = 104
bright_magenta = 105
bright_cyan = 106
bright_white = 107

def __str__(self) -> str:
"""
Return ANSI color sequence instead of enum name
This is helpful when using a bg in an f-string or format() call
e.g. my_str = f"{bg.black}hello{bg.reset}"
"""
return f"{CSI}{self.value}m"
2 changes: 0 additions & 2 deletions tests/test_ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ def test_cursor():
@pytest.mark.parametrize(
'ansi_sequence',
[
ansi.fg.green,
ansi.bg.blue,
ansi.Fg.MAGENTA,
ansi.Bg.LIGHT_GRAY,
ansi.EightBitBg.CHARTREUSE_2A,
Expand Down

0 comments on commit f217861

Please sign in to comment.