Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b42386b

Browse filesBrowse files
committed
tabular --checkup output with purpose column
adding optional dependencies, to help the user deduce why /llm or .| might not be working in a particular install.
1 parent 82faf17 commit b42386b
Copy full SHA for b42386b

3 files changed

+58-31Lines changed: 58 additions & 31 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎changelog.md‎

Copy file name to clipboardExpand all lines: changelog.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Upcoming (TBD)
22
==============
33

4+
Features
5+
---------
6+
* Show purpose in tabular `--checkup` output.
7+
* Add optional dependencies to `--checkup`.
8+
9+
410
Documentation
511
---------
612
* Add `.|` and `.>` to TIPS.
Collapse file

‎mycli/main_modes/checkup.py‎

Copy file name to clipboardExpand all lines: mycli/main_modes/checkup.py
+34-21Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import urllib.error
77
import urllib.request
88

9+
from tabulate import tabulate
10+
911
from mycli.constants import REPO_URL
1012

1113
PYPI_API_BASE = 'https://pypi.org/pypi'
@@ -24,48 +26,59 @@ def pypi_api_fetch(fragment: str) -> dict:
2426

2527
def _dependencies_checkup() -> None:
2628
print('\n### Key Python dependencies:\n')
27-
for dependency in [
28-
'cli_helpers',
29-
'click',
30-
'prompt_toolkit',
31-
'pygments',
32-
'pymysql',
33-
'sqlglot',
34-
'sqlglotc',
35-
'tabulate',
29+
table = []
30+
for dependency, purpose in [
31+
('cli_helpers', 'required'),
32+
('click', 'required'),
33+
('prompt_toolkit', 'required'),
34+
('pygments', 'required'),
35+
('pymysql', 'required'),
36+
('sqlglot', 'required'),
37+
('sqlglotc', 'required'),
38+
('tabulate', 'required'),
39+
('llm', 'optional for /llm command'),
40+
('polars', 'optional for .| operator'),
41+
('altair', 'optional for .| operator'),
42+
('vl-convert-python', 'optional for .| operator'),
3643
]:
3744
try:
3845
installed_version = importlib.metadata.version(dependency)
3946
except importlib.metadata.PackageNotFoundError:
4047
installed_version = None
4148
pypi_profile = pypi_api_fetch(f'/{dependency}/json')
4249
latest_version = pypi_profile.get('info', {}).get('version', None)
43-
print(f'{dependency} version {installed_version} (latest {latest_version})')
50+
table.append([dependency, installed_version, latest_version, purpose])
51+
print(tabulate(table, headers=['library', 'version', 'latest', 'purpose']))
4452

4553

4654
def _executables_checkup() -> None:
4755
print('\n### External executables:\n')
48-
for executable in [
49-
'less',
50-
'fzf',
51-
'pygmentize',
56+
table = []
57+
for executable, purpose in [
58+
('less', 'required for paging'),
59+
('fzf', r'optional for history search and \x'),
60+
('pygmentize', 'optional for history search'),
5261
]:
62+
# executable, purpose = external
5363
if shutil.which(executable):
54-
print(f'The "{executable}" executable was found — good!')
64+
table.append([executable, 'found', purpose])
5565
else:
56-
print(f'The recommended "{executable}" executable was not found — some functionality will suffer.')
66+
table.append([executable, 'MISSING', purpose])
67+
print(tabulate(table, headers=['executable', 'status', 'purpose']))
5768

5869

5970
def _environment_checkup() -> None:
6071
print('\n### Environment variables:\n')
61-
for variable in [
62-
'EDITOR',
63-
'VISUAL',
72+
table = []
73+
for variable, purpose in [
74+
('EDITOR', r'optional for \edit and C-x C-e'),
75+
('VISUAL', r'optional for \edit and C-x C-e'),
6476
]:
6577
if value := os.environ.get(variable):
66-
print(f'The ${variable} environment variable was set to "{value}" — good!')
78+
table.append([f'${variable}', value, purpose])
6779
else:
68-
print(f'The ${variable} environment variable was not set — some functionality will suffer.')
80+
table.append([f'${variable}', 'UNSET', purpose])
81+
print(tabulate(table, headers=['variable', 'setting', 'purpose']))
6982

7083

7184
def _configuration_checkup(mycli) -> None:
Collapse file

‎test/pytests/test_checkup.py‎

Copy file name to clipboardExpand all lines: test/pytests/test_checkup.py
+18-10Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def test_dependencies_checkup(monkeypatch, capsys) -> None:
5050
'pygments': '2.19.2',
5151
'sqlglot': '30.7.0',
5252
'sqlglotc': '30.7.0',
53+
'tabulate': '0.10.0',
54+
'llm': '0.30',
55+
'polars': '1.42.1',
56+
'altair': '6.2.2',
57+
'vl-convert-python': '1.9.0',
5358
}
5459

5560
def fake_version(name: str) -> str:
@@ -68,11 +73,12 @@ def fake_pypi_api_fetch(fragment: str) -> dict:
6873
output = capsys.readouterr().out
6974

7075
assert '### Key Python dependencies:' in output
71-
assert 'cli_helpers version 1.0.0 (latest latest-cli_helpers)' in output
72-
assert 'click version 2.0.0 (latest latest-click)' in output
73-
assert 'prompt_toolkit version 3.0.0 (latest latest-prompt_toolkit)' in output
74-
assert 'pymysql version 4.0.0 (latest latest-pymysql)' in output
75-
assert 'tabulate version None (latest latest-tabulate)' in output
76+
rows = [line.split() for line in output.splitlines()]
77+
assert ['cli_helpers', '1.0.0', 'latest-cli_helpers', 'required'] in rows
78+
assert ['click', '2.0.0', 'latest-click', 'required'] in rows
79+
assert ['prompt_toolkit', '3.0.0', 'latest-prompt_toolkit', 'required'] in rows
80+
assert ['pymysql', '4.0.0', 'latest-pymysql', 'required'] in rows
81+
assert ['tabulate', 'latest-tabulate', 'required'] in rows
7682

7783

7884
def test_executables_checkup(monkeypatch, capsys) -> None:
@@ -86,9 +92,10 @@ def test_executables_checkup(monkeypatch, capsys) -> None:
8692
output = capsys.readouterr().out
8793

8894
assert '### External executables:' in output
89-
assert 'The "less" executable was found' in output
90-
assert 'The recommended "fzf" executable was not found' in output
91-
assert 'The "pygmentize" executable was found' in output
95+
rows = [line.split() for line in output.splitlines()]
96+
assert ['less', 'found', 'required', 'for', 'paging'] in rows
97+
assert ['fzf', 'MISSING', 'optional', 'for', 'history', 'search', 'and', r'\x'] in rows
98+
assert ['pygmentize', 'found', 'optional', 'for', 'history', 'search'] in rows
9299

93100

94101
def test_environment_checkup(monkeypatch, capsys) -> None:
@@ -99,8 +106,9 @@ def test_environment_checkup(monkeypatch, capsys) -> None:
99106
output = capsys.readouterr().out
100107

101108
assert '### Environment variables:' in output
102-
assert 'The $EDITOR environment variable was set to "vim" ' in output
103-
assert 'The $VISUAL environment variable was not set' in output
109+
rows = [line.split() for line in output.splitlines()]
110+
assert ['$EDITOR', 'vim', 'optional', 'for', r'\edit', 'and', 'C-x', 'C-e'] in rows
111+
assert ['$VISUAL', 'UNSET', 'optional', 'for', r'\edit', 'and', 'C-x', 'C-e'] in rows
104112

105113

106114
def test_configuration_checkup_missing_file(capsys) -> None:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.