Skip to content

Commit b40e1d5

Browse files
jlopezclaude
andauthored
fix(deps): make typer an optional dependency (#40)
Move typer to a `cli` optional extra so library consumers (e.g. the jackery-ha Home Assistant integration) don't pull in typer/rich, which can conflict with pre-installed versions in the HA Docker image. Guard the typer import in cli.py with a friendly error message when the extra is not installed. Fixes: #39 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 26e9514 commit b40e1d5

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ the device or its firmware.
1313
## Quick start
1414

1515
```bash
16-
uvx socketry login --email you@example.com --password 'yourpass'
17-
uvx socketry get
16+
uvx 'socketry[cli]' login --email you@example.com --password 'yourpass'
17+
uvx 'socketry[cli]' get
1818
```
1919

2020
Or install it once and use `socketry` directly:
2121

2222
```bash
23-
uv tool install socketry
23+
uv tool install 'socketry[cli]'
2424
socketry login --email you@example.com --password 'yourpass'
2525
socketry get
2626
```
@@ -49,13 +49,16 @@ properties returned by newer firmware are displayed as raw key/value pairs.
4949

5050
```bash
5151
# Install as a CLI tool
52-
uv tool install socketry
52+
uv tool install 'socketry[cli]'
5353

5454
# Or run directly without installing
55-
uvx socketry --help
55+
uvx 'socketry[cli]' --help
5656

57-
# Or install as a library
57+
# Or install as a library only (no CLI dependencies)
5858
pip install socketry
59+
60+
# Or install with CLI included
61+
pip install 'socketry[cli]'
5962
```
6063

6164
## CLI usage

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ authors = [
99
requires-python = ">=3.11"
1010
license = "MIT"
1111
dependencies = [
12-
"typer>=0.9",
1312
"aiomqtt>=2.0",
1413
"aiohttp>=3.9",
1514
"pycryptodome>=3.19",
1615
]
1716

17+
[project.optional-dependencies]
18+
cli = ["typer>=0.9"]
19+
1820
[project.scripts]
1921
socketry = "socketry.cli:app"
2022

@@ -24,6 +26,7 @@ build-backend = "uv_build"
2426

2527
[dependency-groups]
2628
dev = [
29+
"socketry[cli]",
2730
"aioresponses>=0.7",
2831
"mypy>=1.19.1",
2932
"pre-commit>=4.5.1",

src/socketry/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
import sys
99
from datetime import datetime
1010

11-
import typer
11+
try:
12+
import typer
13+
except ImportError:
14+
raise SystemExit("socketry CLI requires the 'cli' extra: pip install socketry[cli]") from None
1215

1316
from socketry.client import Client
1417
from socketry.properties import GROUP_TITLES, MODEL_NAMES, PROPERTIES, Setting, resolve

uv.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)