Skip to content

Commit b57e452

Browse files
committed
Linting.
1 parent 86cf84d commit b57e452

12 files changed

+112
-149
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ repos:
6363
- id: yapf-isort
6464
exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup)\.py$
6565

66-
# Custom hooks can be added below this comment
67-
6866
- repo: https://github.com/domdfcoding/dep_checker
69-
rev: v0.2.0
67+
rev: v0.3.1
7068
hooks:
7169
- id: dep_checker
7270
args:
7371
- consolekit
72+
73+
# Custom hooks can be added below this comment

consolekit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def resolve_command(self, ctx, args): # noqa: D102
100100
message = [f"No such command '{original_cmd_name}'."]
101101
if closest:
102102
message.append(f"The most similar command is {closest[0]!r}.")
103-
ctx.fail("\n".join(message))
103+
ctx.fail('\n'.join(message))
104104

105105
return cmd_name, cmd, args[1:]
106106

consolekit/input.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ def confirm(
226226
except (KeyboardInterrupt, EOFError):
227227
raise click.Abort()
228228

229-
if value in ("y", "yes"):
229+
if value in ('y', "yes"):
230230
rv = True
231-
elif value in ("n", "no"):
231+
elif value in ('n', "no"):
232232
rv = False
233233
elif value == '':
234234
rv = default
@@ -279,7 +279,7 @@ def stderr_input(prompt: str = '', file: IO = sys.stdout) -> str: # pragma: no
279279

280280
if not line: # inputting an empty line gives line == '\n'
281281
raise EOFError
282-
elif line[-1] == "\n":
282+
elif line[-1] == '\n':
283283
return line[:-1]
284284

285285
return line

consolekit/terminal_colours.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@
100100

101101
init()
102102

103-
CSI: Final[str] = "\033["
104-
OSC: Final[str] = "\033]"
105-
BEL: Final[str] = "\a"
103+
CSI: Final[str] = "\u001b["
104+
OSC: Final[str] = "\u001b]"
105+
BEL: Final[str] = '\x07'
106106

107107
fore_stack: List[str] = []
108108
back_stack: List[str] = []
@@ -312,7 +312,7 @@ class AnsiFore(AnsiCodes):
312312
"""
313313

314314
_stack = fore_stack
315-
_reset = "\033[39m"
315+
_reset = "\u001b[39m"
316316

317317
BLACK = 30
318318
RED = 31
@@ -363,7 +363,7 @@ class AnsiBack(AnsiCodes):
363363
"""
364364

365365
_stack = back_stack
366-
_reset = "\033[49m"
366+
_reset = "\u001b[49m"
367367

368368
BLACK = 40
369369
RED = 41
@@ -401,7 +401,7 @@ class AnsiStyle(AnsiCodes):
401401
"""
402402

403403
_stack = style_stack
404-
_reset = "\033[22m"
404+
_reset = "\u001b[22m"
405405

406406
BRIGHT = 1
407407
DIM = 2

consolekit/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def coloured_diff(
130130
fromfiledate: str = '',
131131
tofiledate: str = '',
132132
n: int = 3,
133-
lineterm: str = "\n",
133+
lineterm: str = '\n',
134134
removed_colour: Colour = Fore.RED,
135135
added_colour: Colour = Fore.GREEN,
136136
) -> str:

lint_roller.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
@pytest.fixture()
1010
def original_datadir(request) -> Path:
1111
# Work around pycharm confusing datadir with test file.
12-
return Path(os.path.splitext(request.module.__file__)[0] + "_")
12+
return Path(os.path.splitext(request.module.__file__)[0] + '_')

tests/test_input.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
def test_choice_letters(capsys, monkeypatch, data_regression: DataRegressionFixture):
1212

13-
inputs = iter(["F", "G", "D"])
13+
inputs = iter(['F', 'G', 'D'])
1414

1515
def fake_input(prompt):
1616
value = next(inputs)
@@ -24,19 +24,19 @@ def fake_input(prompt):
2424
echo("==> Package distributor has shipped an updated version.")
2525
echo("What would you like to do about it ? Your options are:")
2626
options = {
27-
"Y": "install the package maintainer's version",
28-
"N": "keep your currently-installed version",
29-
"D": "show the differences between the versions",
30-
"Z": "start a shell to examine the situation"
27+
'Y': "install the package maintainer's version",
28+
'N': "keep your currently-installed version",
29+
'D': "show the differences between the versions",
30+
'Z': "start a shell to examine the situation"
3131
}
32-
assert choice(text="*** sudoers", options=options, default="N") == "D"
32+
assert choice(text="*** sudoers", options=options, default='N') == 'D'
3333

3434
data_regression.check(list(StringList(capsys.readouterr().out.splitlines())))
3535

3636

3737
def test_choice_numbers(capsys, monkeypatch, data_regression: DataRegressionFixture):
3838

39-
inputs = iter(["20", "0", "5"])
39+
inputs = iter(["20", '0', '5'])
4040

4141
def fake_input(prompt):
4242
value = next(inputs)
@@ -55,14 +55,14 @@ def fake_input(prompt):
5555
"Mature",
5656
"Inactive",
5757
]
58-
assert choice(text="", options=options, start_index=1) == 4
58+
assert choice(text='', options=options, start_index=1) == 4
5959

6060
data_regression.check(list(StringList(capsys.readouterr().out.splitlines())))
6161

6262

6363
def test_confirm(capsys, monkeypatch, data_regression: DataRegressionFixture):
6464

65-
inputs = iter(["Y", "N", "", ""])
65+
inputs = iter(['Y', 'N', '', ''])
6666

6767
def fake_input(prompt):
6868
value = next(inputs)
@@ -81,7 +81,7 @@ def fake_input(prompt):
8181

8282
def test_prompt(capsys, monkeypatch, data_regression: DataRegressionFixture):
8383

84-
inputs = iter(["", "", "", "", "24", "Bond007", "badpassword", "baspassword", "badpassword", "badpassword"])
84+
inputs = iter(['', '', '', '', "24", "Bond007", "badpassword", "baspassword", "badpassword", "badpassword"])
8585

8686
def fake_input(prompt):
8787
value = next(inputs)

tests/test_terminal_colours.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44

55
def test_terminal_colours_constants():
6-
assert terminal_colours.CSI == "\033["
7-
assert terminal_colours.OSC == "\033]"
8-
assert terminal_colours.BEL == "\a"
6+
assert terminal_colours.CSI == "\u001b["
7+
assert terminal_colours.OSC == "\u001b]"
8+
assert terminal_colours.BEL == '\x07'
99

1010

1111
def test_terminal_colours_stacks():
@@ -15,47 +15,47 @@ def test_terminal_colours_stacks():
1515

1616

1717
def test_terminal_colours_functions():
18-
assert terminal_colours.set_title("Foo") == "\033]2;Foo\a"
18+
assert terminal_colours.set_title("Foo") == "\u001b]2;Foo\u0007"
1919

2020
# assert terminal_colours.clear_screen() == "\033[2J"
2121
# assert terminal_colours.clear_screen(1) == "\033[1J"
2222

23-
assert terminal_colours.clear_line() == "\033[2K"
24-
assert terminal_colours.clear_line(1) == "\033[1K"
23+
assert terminal_colours.clear_line() == "\u001b[2K"
24+
assert terminal_colours.clear_line(1) == "\u001b[1K"
2525

2626

2727
def test_ansi_cursor():
28-
assert terminal_colours.Cursor.UP() == "\033[1A"
29-
assert terminal_colours.Cursor.UP(1) == "\033[1A"
30-
assert terminal_colours.Cursor.UP(2) == "\033[2A"
31-
assert terminal_colours.Cursor.UP(3) == "\033[3A"
32-
33-
assert terminal_colours.Cursor.DOWN() == "\033[1B"
34-
assert terminal_colours.Cursor.DOWN(1) == "\033[1B"
35-
assert terminal_colours.Cursor.DOWN(2) == "\033[2B"
36-
assert terminal_colours.Cursor.DOWN(3) == "\033[3B"
37-
38-
assert terminal_colours.Cursor.FORWARD() == "\033[1C"
39-
assert terminal_colours.Cursor.FORWARD(1) == "\033[1C"
40-
assert terminal_colours.Cursor.FORWARD(2) == "\033[2C"
41-
assert terminal_colours.Cursor.FORWARD(3) == "\033[3C"
42-
43-
assert terminal_colours.Cursor.BACK() == "\033[1D"
44-
assert terminal_colours.Cursor.BACK(1) == "\033[1D"
45-
assert terminal_colours.Cursor.BACK(2) == "\033[2D"
46-
assert terminal_colours.Cursor.BACK(3) == "\033[3D"
47-
48-
assert terminal_colours.Cursor.POS() == "\033[1;1H"
49-
assert terminal_colours.Cursor.POS(1) == "\033[1;1H"
50-
assert terminal_colours.Cursor.POS(2) == "\033[1;2H"
51-
assert terminal_colours.Cursor.POS(3) == "\033[1;3H"
52-
assert terminal_colours.Cursor.POS(y=1) == "\033[1;1H"
53-
assert terminal_colours.Cursor.POS(y=2) == "\033[2;1H"
54-
assert terminal_colours.Cursor.POS(y=3) == "\033[3;1H"
55-
assert terminal_colours.Cursor.POS(x=1) == "\033[1;1H"
56-
assert terminal_colours.Cursor.POS(x=2) == "\033[1;2H"
57-
assert terminal_colours.Cursor.POS(x=3) == "\033[1;3H"
58-
assert terminal_colours.Cursor.POS(1, 1) == "\033[1;1H"
59-
assert terminal_colours.Cursor.POS(2, 2) == "\033[2;2H"
60-
assert terminal_colours.Cursor.POS(3, 3) == "\033[3;3H"
61-
assert terminal_colours.Cursor.POS(x=2, y=3) == "\033[3;2H"
28+
assert terminal_colours.Cursor.UP() == "\u001b[1A"
29+
assert terminal_colours.Cursor.UP(1) == "\u001b[1A"
30+
assert terminal_colours.Cursor.UP(2) == "\u001b[2A"
31+
assert terminal_colours.Cursor.UP(3) == "\u001b[3A"
32+
33+
assert terminal_colours.Cursor.DOWN() == "\u001b[1B"
34+
assert terminal_colours.Cursor.DOWN(1) == "\u001b[1B"
35+
assert terminal_colours.Cursor.DOWN(2) == "\u001b[2B"
36+
assert terminal_colours.Cursor.DOWN(3) == "\u001b[3B"
37+
38+
assert terminal_colours.Cursor.FORWARD() == "\u001b[1C"
39+
assert terminal_colours.Cursor.FORWARD(1) == "\u001b[1C"
40+
assert terminal_colours.Cursor.FORWARD(2) == "\u001b[2C"
41+
assert terminal_colours.Cursor.FORWARD(3) == "\u001b[3C"
42+
43+
assert terminal_colours.Cursor.BACK() == "\u001b[1D"
44+
assert terminal_colours.Cursor.BACK(1) == "\u001b[1D"
45+
assert terminal_colours.Cursor.BACK(2) == "\u001b[2D"
46+
assert terminal_colours.Cursor.BACK(3) == "\u001b[3D"
47+
48+
assert terminal_colours.Cursor.POS() == "\u001b[1;1H"
49+
assert terminal_colours.Cursor.POS(1) == "\u001b[1;1H"
50+
assert terminal_colours.Cursor.POS(2) == "\u001b[1;2H"
51+
assert terminal_colours.Cursor.POS(3) == "\u001b[1;3H"
52+
assert terminal_colours.Cursor.POS(y=1) == "\u001b[1;1H"
53+
assert terminal_colours.Cursor.POS(y=2) == "\u001b[2;1H"
54+
assert terminal_colours.Cursor.POS(y=3) == "\u001b[3;1H"
55+
assert terminal_colours.Cursor.POS(x=1) == "\u001b[1;1H"
56+
assert terminal_colours.Cursor.POS(x=2) == "\u001b[1;2H"
57+
assert terminal_colours.Cursor.POS(x=3) == "\u001b[1;3H"
58+
assert terminal_colours.Cursor.POS(1, 1) == "\u001b[1;1H"
59+
assert terminal_colours.Cursor.POS(2, 2) == "\u001b[2;2H"
60+
assert terminal_colours.Cursor.POS(3, 3) == "\u001b[3;3H"
61+
assert terminal_colours.Cursor.POS(x=2, y=3) == "\u001b[3;2H"

0 commit comments

Comments
 (0)