Skip to content

Commit 9e750bb

Browse files
committed
Renamed functions in cmd2.ansi.Cursor to be pep8 compliant
1 parent 62802c8 commit 9e750bb

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

cmd2/ansi.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,33 +207,33 @@ class BgColor(AnsiSequence):
207207

208208

209209
####################################################################################
210-
# Implementations intended for direct use
210+
# Implementations intended for direct use (do NOT use outside of cmd2)
211211
####################################################################################
212212
class Cursor:
213213
"""Create ANSI sequences to alter the cursor position."""
214214

215215
@staticmethod
216-
def UP(count: int = 1) -> str:
216+
def up(count: int = 1) -> str:
217217
"""Move the cursor up a specified amount of lines (Defaults to 1)."""
218218
return f"{CSI}{count}A"
219219

220220
@staticmethod
221-
def DOWN(count: int = 1) -> str:
221+
def down(count: int = 1) -> str:
222222
"""Move the cursor down a specified amount of lines (Defaults to 1)."""
223223
return f"{CSI}{count}B"
224224

225225
@staticmethod
226-
def FORWARD(count: int = 1) -> str:
226+
def forward(count: int = 1) -> str:
227227
"""Move the cursor forward a specified amount of lines (Defaults to 1)."""
228228
return f"{CSI}{count}C"
229229

230230
@staticmethod
231-
def BACK(count: int = 1) -> str:
231+
def back(count: int = 1) -> str:
232232
"""Move the cursor back a specified amount of lines (Defaults to 1)."""
233233
return f"{CSI}{count}D"
234234

235235
@staticmethod
236-
def SET_POS(x: int, y: int) -> str:
236+
def set_pos(x: int, y: int) -> str:
237237
"""Set the cursor position to coordinates which are 1-based."""
238238
return f"{CSI}{y};{x}H"
239239

@@ -1059,11 +1059,11 @@ def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_off
10591059

10601060
# Move the cursor down to the last input line
10611061
if cursor_input_line != num_input_terminal_lines:
1062-
terminal_str += Cursor.DOWN(num_input_terminal_lines - cursor_input_line)
1062+
terminal_str += Cursor.down(num_input_terminal_lines - cursor_input_line)
10631063

10641064
# Clear each line from the bottom up so that the cursor ends up on the first prompt line
10651065
total_lines = num_prompt_terminal_lines + num_input_terminal_lines
1066-
terminal_str += (clear_line() + Cursor.UP(1)) * (total_lines - 1)
1066+
terminal_str += (clear_line() + Cursor.up(1)) * (total_lines - 1)
10671067

10681068
# Clear the first prompt line
10691069
terminal_str += clear_line()

pyproject.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,6 @@ per-file-ignores."cmd2/argparse_custom.py" = [
260260
"UP031", # Use format specifiers instead of percent format (auto fix is unsafe)
261261
]
262262

263-
per-file-ignores."cmd2/ansi.py" = [
264-
"N802", # Function names should be lowercase for things like Curor.UP
265-
]
266-
267263
per-file-ignores."examples/*.py" = [
268264
"ANN", # Ignore all type annotation rules in examples folder
269265
"D", # Ignore all pydocstyle rules in examples folder

tests/test_ansi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ def test_clear_line() -> None:
202202

203203
def test_cursor() -> None:
204204
count = 1
205-
assert ansi.Cursor.UP(count) == f"{ansi.CSI}{count}A"
206-
assert ansi.Cursor.DOWN(count) == f"{ansi.CSI}{count}B"
207-
assert ansi.Cursor.FORWARD(count) == f"{ansi.CSI}{count}C"
208-
assert ansi.Cursor.BACK(count) == f"{ansi.CSI}{count}D"
205+
assert ansi.Cursor.up(count) == f"{ansi.CSI}{count}A"
206+
assert ansi.Cursor.down(count) == f"{ansi.CSI}{count}B"
207+
assert ansi.Cursor.forward(count) == f"{ansi.CSI}{count}C"
208+
assert ansi.Cursor.back(count) == f"{ansi.CSI}{count}D"
209209

210210
x = 4
211211
y = 5
212-
assert ansi.Cursor.SET_POS(x, y) == f"{ansi.CSI}{y};{x}H"
212+
assert ansi.Cursor.set_pos(x, y) == f"{ansi.CSI}{y};{x}H"
213213

214214

215215
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)