datalegion-cli 1.10.2__tar.gz → 1.10.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/PKG-INFO +1 -13
  2. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/README.md +0 -12
  3. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/pyproject.toml +12 -3
  4. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/client.py +33 -7
  5. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/commands/__init__.py +1 -1
  6. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/commands/company.py +0 -31
  7. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/commands/person.py +0 -32
  8. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/config.py +2 -13
  9. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/logging.py +1 -1
  10. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/login.py +2 -1
  11. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/main.py +0 -8
  12. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/update.py +1 -3
  13. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_client.py +1 -12
  14. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_commands.py +1 -53
  15. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/.gitignore +0 -0
  16. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/LICENSE +0 -0
  17. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/__init__.py +0 -0
  18. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/async_typer.py +0 -0
  19. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/commands/credits.py +0 -0
  20. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/commands/utility.py +0 -0
  21. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/src/datalegion_cli/output.py +0 -0
  22. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/__init__.py +0 -0
  23. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/conftest.py +0 -0
  24. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_config.py +0 -0
  25. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_live.py +0 -0
  26. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_logging.py +0 -0
  27. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_login.py +0 -0
  28. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_output.py +0 -0
  29. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_package_contents.py +0 -0
  30. {datalegion_cli-1.10.2 → datalegion_cli-1.10.3}/tests/test_update.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datalegion-cli
3
- Version: 1.10.2
3
+ Version: 1.10.3
4
4
  Summary: CLI for the Data Legion API — agent-friendly, fully async
5
5
  Project-URL: Homepage, https://www.datalegion.ai
6
6
  Project-URL: Documentation, https://www.datalegion.ai/docs
@@ -199,17 +199,6 @@ For deep paging, pass each page's `next_cursor` back with `--cursor`; the last p
199
199
  datalegion-cli person search --filters '{"state_code": "OH"}' --limit 100 --cursor "<next_cursor from the last page>"
200
200
  ```
201
201
 
202
- ### Count Before You Search
203
-
204
- `count` takes what `search` takes and prints how many records match, rounded, without returning any. It is free and works with zero credits left: it needs an active plan that includes search (10 a minute and 100 an hour; 5 and 30 on a free trial). Fields that identify one record (ids, names, emails, phones, URLs, domains, tickers) are refused: use `enrich` for one record.
205
-
206
- ```bash
207
- datalegion-cli person count --filters '{"job_title": "nurse practitioner", "company_industry": "hospitals and health care"}'
208
- # {"total": 110000, "total_status": "about"}
209
- ```
210
-
211
- `total_status` is `about`, `at_least` (counting ran out of time: a lower bound) or `under` (fewer than 10).
212
-
213
202
  ### Person Discover (Beta)
214
203
 
215
204
  ```bash
@@ -251,7 +240,6 @@ datalegion-cli company enrich --name "Stripe" --industry "Financial Services"
251
240
  ```bash
252
241
  datalegion-cli company search --filters '{"industry": "software development", "locations.city": "austin", "locations.primary": true}'
253
242
  datalegion-cli company search --sql "SELECT * FROM companies WHERE industry ILIKE '%software%' AND legion_employee_count > 100"
254
- datalegion-cli company count --filters '{"industry": "banking", "locations.country_code": "GB"}'
255
243
  ```
256
244
 
257
245
  ### Company Discover (Beta)
@@ -164,17 +164,6 @@ For deep paging, pass each page's `next_cursor` back with `--cursor`; the last p
164
164
  datalegion-cli person search --filters '{"state_code": "OH"}' --limit 100 --cursor "<next_cursor from the last page>"
165
165
  ```
166
166
 
167
- ### Count Before You Search
168
-
169
- `count` takes what `search` takes and prints how many records match, rounded, without returning any. It is free and works with zero credits left: it needs an active plan that includes search (10 a minute and 100 an hour; 5 and 30 on a free trial). Fields that identify one record (ids, names, emails, phones, URLs, domains, tickers) are refused: use `enrich` for one record.
170
-
171
- ```bash
172
- datalegion-cli person count --filters '{"job_title": "nurse practitioner", "company_industry": "hospitals and health care"}'
173
- # {"total": 110000, "total_status": "about"}
174
- ```
175
-
176
- `total_status` is `about`, `at_least` (counting ran out of time: a lower bound) or `under` (fewer than 10).
177
-
178
167
  ### Person Discover (Beta)
179
168
 
180
169
  ```bash
@@ -216,7 +205,6 @@ datalegion-cli company enrich --name "Stripe" --industry "Financial Services"
216
205
  ```bash
217
206
  datalegion-cli company search --filters '{"industry": "software development", "locations.city": "austin", "locations.primary": true}'
218
207
  datalegion-cli company search --sql "SELECT * FROM companies WHERE industry ILIKE '%software%' AND legion_employee_count > 100"
219
- datalegion-cli company count --filters '{"industry": "banking", "locations.country_code": "GB"}'
220
208
  ```
221
209
 
222
210
  ### Company Discover (Beta)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "datalegion-cli"
3
- version = "1.10.2"
3
+ version = "1.10.3"
4
4
  description = "CLI for the Data Legion API — agent-friendly, fully async"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -90,14 +90,23 @@ select = [
90
90
  "SIM", # flake8-simplify
91
91
  "TCH", # flake8-type-checking
92
92
  "RUF", # ruff-specific rules
93
+ "ERA", # commented-out code
94
+ "W505", # comment and docstring width
93
95
  ]
94
96
  ignore = [
95
97
  "E501", # line length (handled by formatter)
96
98
  ]
97
99
 
100
+ [tool.ruff.lint.pycodestyle]
101
+ max-doc-length = 100
102
+
98
103
  [tool.ruff.lint.per-file-ignores]
99
- # A byte-identical copy of datalegion-shared's module, held to shared's lint, not edited here
100
- "tests/_conventions.py" = ["SIM", "TC"]
104
+ # A byte-identical copy of the shared conventions module, held to its source's lint, not edited here
105
+ "tests/_conventions.py" = ["SIM", "TC", "W505"]
106
+ # Copied byte for byte across the fleet's repos
107
+ ".github/scripts/check_workflow_names.py" = ["W505"]
108
+ # Typer --help text, whose examples are copy-paste commands
109
+ "src/datalegion_cli/commands/{company,person,utility}.py" = ["W505"]
101
110
 
102
111
  [tool.ruff.lint.isort]
103
112
  known-first-party = ["datalegion_cli"]
@@ -15,6 +15,7 @@ class APIError(Exception):
15
15
  """Raised on non-2xx API responses."""
16
16
 
17
17
  def __init__(self, status_code: int, error: str, message: str, details: Any = None):
18
+ """Keep the API's status, error code, message and details."""
18
19
  self.status_code = status_code
19
20
  self.error = error
20
21
  self.message = message
@@ -22,6 +23,7 @@ class APIError(Exception):
22
23
  super().__init__(f"[{status_code}] {error}: {message}")
23
24
 
24
25
  def to_dict(self) -> dict[str, Any]:
26
+ """The error as JSON output: status_code, error, message, and details when there are any."""
25
27
  d: dict[str, Any] = {
26
28
  "status_code": self.status_code,
27
29
  "error": self.error,
@@ -32,8 +34,8 @@ class APIError(Exception):
32
34
  return d
33
35
 
34
36
 
35
- # Endpoints the API mirrors under /sandbox/: sample records (Jane Sandbox, Sandbox Corp), no credits.
36
- # Utilities, reports, credits and dynamic bulk have no sandbox and call the real API.
37
+ # Endpoints the API mirrors under /sandbox/: sample records (Jane Sandbox, Sandbox Corp), no
38
+ # credits. Utilities, reports, credits and dynamic bulk have no sandbox and call the real API.
37
39
  SANDBOX_PATHS = frozenset(
38
40
  f"/{entity}/{op}"
39
41
  for entity in ("person", "company")
@@ -51,6 +53,11 @@ class LegionClient:
51
53
  api_key: str | None = None,
52
54
  timeout: float = 60.0,
53
55
  ):
56
+ """Use the given base URL and key, else the configured ones (``config set``, ``LEGION_*``).
57
+
58
+ Raises:
59
+ SystemExit: no API key is given or configured.
60
+ """
54
61
  self._base_url = base_url or get_base_url()
55
62
  self._api_key = (api_key or "").strip() or get_api_key()
56
63
  self._timeout = timeout
@@ -68,14 +75,14 @@ class LegionClient:
68
75
  headers={
69
76
  "API-Key": self._api_key,
70
77
  "Content-Type": "application/json",
71
- # Lets the API tell CLI traffic apart (its request log
72
- # classifies datalegion-cli/* as 'cli').
78
+ # Lets the API tell CLI traffic apart
73
79
  "User-Agent": f"datalegion-cli/{__version__}",
74
80
  },
75
81
  )
76
82
  return self._client
77
83
 
78
84
  async def close(self) -> None:
85
+ """Close the HTTP connection, if one is open."""
79
86
  if self._client and not self._client.is_closed:
80
87
  await self._client.aclose()
81
88
 
@@ -87,6 +94,12 @@ class LegionClient:
87
94
  payload: dict[str, Any] | None = None,
88
95
  params: dict[str, Any] | None = None,
89
96
  ) -> dict[str, Any] | list[Any]:
97
+ """Call the API and return its JSON body, via /sandbox/ in sandbox mode where it exists.
98
+
99
+ Raises:
100
+ APIError: the API answered 400 or above.
101
+ httpx.HTTPError: the request timed out or could not connect (raised unchanged).
102
+ """
90
103
  client = await self._get_client()
91
104
  if self._sandbox and endpoint in SANDBOX_PATHS:
92
105
  endpoint = f"/sandbox{endpoint}"
@@ -114,7 +127,6 @@ class LegionClient:
114
127
  message=resp.text,
115
128
  ) from exc
116
129
 
117
- # Expose credit headers
118
130
  self.last_credits_used = resp.headers.get("Credits-Used")
119
131
  self.last_credits_remaining = resp.headers.get("Credits-Remaining")
120
132
  # search/discover: why a filter was flagged and what to change
@@ -122,54 +134,68 @@ class LegionClient:
122
134
 
123
135
  return resp.json()
124
136
 
125
- # ── Convenience methods ──────────────────────────────────────────
126
-
127
137
  async def person_enrich(self, **kwargs: Any) -> dict[str, Any]:
138
+ """POST /person/enrich with the given identifiers; the API's response."""
128
139
  return await self.request("POST", "/person/enrich", payload=_strip(kwargs))
129
140
 
130
141
  async def person_search(self, **kwargs: Any) -> dict[str, Any]:
142
+ """POST /person/search; the API's response."""
131
143
  return await self.request("POST", "/person/search", payload=_strip(kwargs))
132
144
 
133
145
  async def person_count(self, **kwargs: Any) -> dict[str, Any]:
146
+ """POST /person/search/count (free); the API's response."""
134
147
  return await self.request("POST", "/person/search/count", payload=_strip(kwargs))
135
148
 
136
149
  async def person_discover(self, **kwargs: Any) -> dict[str, Any]:
150
+ """POST /person/discover; the API's response."""
137
151
  return await self.request("POST", "/person/discover", payload=_strip(kwargs))
138
152
 
139
153
  async def person_bulk(self, **kwargs: Any) -> dict[str, Any]:
154
+ """POST /person/enrich/bulk; the API's response."""
140
155
  return await self.request("POST", "/person/enrich/bulk", payload=_strip(kwargs))
141
156
 
142
157
  async def company_enrich(self, **kwargs: Any) -> dict[str, Any]:
158
+ """POST /company/enrich with the given identifiers; the API's response."""
143
159
  return await self.request("POST", "/company/enrich", payload=_strip(kwargs))
144
160
 
145
161
  async def company_search(self, **kwargs: Any) -> dict[str, Any]:
162
+ """POST /company/search; the API's response."""
146
163
  return await self.request("POST", "/company/search", payload=_strip(kwargs))
147
164
 
148
165
  async def company_count(self, **kwargs: Any) -> dict[str, Any]:
166
+ """POST /company/search/count (free); the API's response."""
149
167
  return await self.request("POST", "/company/search/count", payload=_strip(kwargs))
150
168
 
151
169
  async def company_discover(self, **kwargs: Any) -> dict[str, Any]:
170
+ """POST /company/discover; the API's response."""
152
171
  return await self.request("POST", "/company/discover", payload=_strip(kwargs))
153
172
 
154
173
  async def company_bulk(self, **kwargs: Any) -> dict[str, Any]:
174
+ """POST /company/enrich/bulk; the API's response."""
155
175
  return await self.request("POST", "/company/enrich/bulk", payload=_strip(kwargs))
156
176
 
157
177
  async def utility_clean(self, **kwargs: Any) -> dict[str, Any]:
178
+ """POST /utility/clean; the API's response."""
158
179
  return await self.request("POST", "/utility/clean", payload=_strip(kwargs))
159
180
 
160
181
  async def utility_hash(self, email: str) -> dict[str, Any]:
182
+ """POST /utility/hash/email; the email's hashes."""
161
183
  return await self.request("POST", "/utility/hash/email", payload={"email": email})
162
184
 
163
185
  async def utility_validate(self, **kwargs: Any) -> dict[str, Any]:
186
+ """POST /utility/validate; the API's response."""
164
187
  return await self.request("POST", "/utility/validate", payload=_strip(kwargs))
165
188
 
166
189
  async def utility_report(self, kind: str, **kwargs: Any) -> dict[str, Any]:
190
+ """POST /utility/report/{kind} (``person`` or ``company``); the API's response."""
167
191
  return await self.request("POST", f"/utility/report/{kind}", payload=_strip(kwargs))
168
192
 
169
193
  async def credits_balance(self) -> dict[str, Any]:
194
+ """GET /credits: the team's balance per contract."""
170
195
  return await self.request("GET", "/credits")
171
196
 
172
197
  async def credits_usage(self, **kwargs: Any) -> dict[str, Any]:
198
+ """GET /credits/usage with the given filters; the API's response."""
173
199
  return await self.request("GET", "/credits/usage", params=_strip(kwargs))
174
200
 
175
201
 
@@ -54,7 +54,7 @@ def _json_object(text: str, what: str) -> dict[str, Any]:
54
54
  def search_inputs(
55
55
  query: str | None, filters: str | None, sql: str | None, es_query: str | None
56
56
  ) -> dict[str, Any]:
57
- """Exactly one of the search inputs, each sent by its own name; the positional query is SQL or a query object."""
57
+ """Exactly one search input, by its own name; a positional query is SQL or a query object."""
58
58
  given = [
59
59
  name
60
60
  for name, v in (
@@ -22,7 +22,6 @@ from datalegion_cli.output import emit_credits, emit_error, emit_json, emit_sear
22
22
 
23
23
  app = typer.Typer(name="company", help="Company Enrichment, Search and Discover.")
24
24
 
25
- # ── Shared options ───────────────────────────────────────────────────
26
25
 
27
26
  TitleOpt = Annotated[bool, typer.Option("--titlecase", help="Title-case text fields.")]
28
27
  LimitOpt = Annotated[int, typer.Option("--limit", "-l", help="Max results.")]
@@ -210,33 +209,3 @@ async def discover(
210
209
  raise typer.Exit(1) from e
211
210
  finally:
212
211
  await client.close()
213
-
214
-
215
- # TODO: Uncomment when bulk enrichment is ready
216
- # @app.command()
217
- # @async_command
218
- # async def bulk(
219
- # file: Annotated[str, typer.Argument(help="Path to JSON file with items array, or '-' for stdin.")],
220
- # titlecase: TitleOpt = False,
221
- # ) -> None:
222
- # """Bulk enrich up to 100 companies from a JSON file."""
223
- # if file == "-":
224
- # data = json.load(sys.stdin)
225
- # else:
226
- # with open(file) as f:
227
- # data = json.load(f)
228
- #
229
- # items = data if isinstance(data, list) else data.get("items", data)
230
- #
231
- # client = LegionClient()
232
- # try:
233
- # result = await client.company_bulk(
234
- # items=items, titlecase=titlecase,
235
- # )
236
- # emit_json(result)
237
- # emit_credits(client.last_credits_used, client.last_credits_remaining)
238
- # except APIError as e:
239
- # emit_error(e.message, code=e.error, details=e.details, as_json=True)
240
- # raise typer.Exit(1) from e
241
- # finally:
242
- # await client.close()
@@ -22,7 +22,6 @@ from datalegion_cli.output import emit_credits, emit_error, emit_json, emit_sear
22
22
 
23
23
  app = typer.Typer(name="person", help="Person Enrichment, Search and Discover.")
24
24
 
25
- # ── Shared options ───────────────────────────────────────────────────
26
25
 
27
26
  TitleOpt = Annotated[bool, typer.Option("--titlecase", help="Title-case text fields in response.")]
28
27
  LimitOpt = Annotated[int, typer.Option("--limit", "-l", help="Max results to return.")]
@@ -241,34 +240,3 @@ async def discover(
241
240
  raise typer.Exit(1) from e
242
241
  finally:
243
242
  await client.close()
244
-
245
-
246
- # TODO: Uncomment when bulk enrichment is ready
247
- # @app.command()
248
- # @async_command
249
- # async def bulk(
250
- # file: Annotated[str, typer.Argument(help="Path to JSON file with items array, or '-' for stdin.")],
251
- # titlecase: TitleOpt = False,
252
- # ) -> None:
253
- # """Bulk enrich up to 100 people from a JSON file."""
254
- # if file == "-":
255
- # data = json.load(sys.stdin)
256
- # else:
257
- # with open(file) as f:
258
- # data = json.load(f)
259
- #
260
- # # Accept either {"items": [...]} or just [...]
261
- # items = data if isinstance(data, list) else data.get("items", data)
262
- #
263
- # client = LegionClient()
264
- # try:
265
- # result = await client.person_bulk(
266
- # items=items, titlecase=titlecase,
267
- # )
268
- # emit_json(result)
269
- # emit_credits(client.last_credits_used, client.last_credits_remaining)
270
- # except APIError as e:
271
- # emit_error(e.message, code=e.error, details=e.details, as_json=True)
272
- # raise typer.Exit(1) from e
273
- # finally:
274
- # await client.close()
@@ -26,13 +26,9 @@ _DEFAULTS: dict[str, object] = {
26
26
  "sandbox": False, # sample records, no credits (see client.SANDBOX_PATHS)
27
27
  }
28
28
 
29
- # Fields that are stored encrypted on disk
30
29
  _ENCRYPTED_FIELDS = {"api_key"}
31
30
 
32
31
 
33
- # ── Encryption helpers ───────────────────────────────────────────────
34
-
35
-
36
32
  def _derive_key() -> bytes:
37
33
  """Derive a Fernet key from machine-specific stable inputs.
38
34
 
@@ -67,9 +63,6 @@ def _decrypt(token: str) -> str:
67
63
  return ""
68
64
 
69
65
 
70
- # ── Config I/O ───────────────────────────────────────────────────────
71
-
72
-
73
66
  def _ensure_dir() -> None:
74
67
  CONFIG_DIR.mkdir(parents=True, exist_ok=True)
75
68
 
@@ -80,12 +73,11 @@ def load_config() -> dict[str, object]:
80
73
  if CONFIG_FILE.exists():
81
74
  with CONFIG_FILE.open("rb") as f:
82
75
  raw = tomllib.load(f)
83
- # Decrypt encrypted fields
84
76
  for field in _ENCRYPTED_FIELDS:
85
77
  if raw.get(field):
86
78
  raw[field] = _decrypt(str(raw[field]))
87
79
  cfg.update(raw)
88
- # Environment overrides (plaintext — user's responsibility)
80
+ # Environment overrides, not encrypted
89
81
  if env_key := os.environ.get("LEGION_API_KEY"):
90
82
  cfg["api_key"] = env_key
91
83
  if env_url := os.environ.get("LEGION_API_URL"):
@@ -104,13 +96,9 @@ def save_config(cfg: dict[str, object]) -> None:
104
96
  to_write[field] = _encrypt(str(to_write[field]))
105
97
  with CONFIG_FILE.open("wb") as f:
106
98
  tomli_w.dump(to_write, f)
107
- # Restrict file permissions (owner read/write only)
108
99
  CONFIG_FILE.chmod(0o600)
109
100
 
110
101
 
111
- # ── Public accessors ─────────────────────────────────────────────────
112
-
113
-
114
102
  def get_api_key() -> str:
115
103
  """Return the configured API key or raise."""
116
104
  # Trimmed: a key from a file or a paste with a trailing newline is otherwise refused by httpx.
@@ -124,6 +112,7 @@ def get_api_key() -> str:
124
112
 
125
113
 
126
114
  def get_base_url() -> str:
115
+ """The configured API base URL, or the default."""
127
116
  return str(load_config().get("api_base_url", _DEFAULTS["api_base_url"]))
128
117
 
129
118
 
@@ -14,7 +14,7 @@ def setup_logging(*, verbose: bool = False, quiet: bool = False) -> None:
14
14
  - --verbose: DEBUG+ to stderr
15
15
  - --quiet: suppress all log output
16
16
  """
17
- logger.remove() # Remove default handler
17
+ logger.remove()
18
18
 
19
19
  if quiet:
20
20
  return
@@ -1,6 +1,6 @@
1
1
  """Sign in from the terminal and get a key for this machine (OAuth device authorization).
2
2
 
3
- ``datalegion-cli login`` asks Data Legion's sign-in server (WorkOS AuthKit) for a
3
+ ``datalegion-cli login`` asks Data Legion's sign-in server for a
4
4
  device code, shows the person a link and a short code to approve, polls until they
5
5
  do, then trades the access token at ``POST /agent/key`` for an API key that belongs
6
6
  to this machine. The key is stored encrypted like one set with ``config set``.
@@ -35,6 +35,7 @@ class LoginError(Exception):
35
35
  """Sign-in failed; the message is fit to show the person."""
36
36
 
37
37
  def __init__(self, message: str, *, code: str = "login_failed", details: Any = None):
38
+ """Keep the message, an error code for JSON output, and any details."""
38
39
  super().__init__(message)
39
40
  self.code = code
40
41
  self.details = details
@@ -23,15 +23,12 @@ app = typer.Typer(
23
23
  rich_markup_mode="rich",
24
24
  )
25
25
 
26
- # ── Register sub-command groups ──────────────────────────────────────
27
26
 
28
27
  app.add_typer(person.app, name="person")
29
28
  app.add_typer(company.app, name="company")
30
29
  app.add_typer(utility.app, name="utility")
31
30
  app.add_typer(credits.app, name="credits")
32
31
 
33
- # ── Global callback for shared flags ────────────────────────────────
34
-
35
32
 
36
33
  @app.callback()
37
34
  def main_callback(
@@ -52,9 +49,6 @@ def main_callback(
52
49
  os.environ["LEGION_SANDBOX"] = "1"
53
50
 
54
51
 
55
- # ── Top-level commands ───────────────────────────────────────────────
56
-
57
-
58
52
  @app.command()
59
53
  @async_command
60
54
  async def version() -> None:
@@ -87,7 +81,6 @@ async def config(
87
81
  return
88
82
 
89
83
  if action == "list":
90
- # Mask the API key for display
91
84
  display = dict(cfg)
92
85
  if display.get("api_key"):
93
86
  display["api_key"] = _mask(str(display["api_key"]))
@@ -106,7 +99,6 @@ async def config(
106
99
  if action == "set":
107
100
  if not key or value is None:
108
101
  raise typer.BadParameter("Both key and value required for 'set'.")
109
- # Type coercion for booleans
110
102
  if value.lower() in ("true", "1", "yes"):
111
103
  cfg[key] = True
112
104
  elif value.lower() in ("false", "0", "no"):
@@ -1,4 +1,4 @@
1
- """Auto-update — checks PyPI for a newer release and self-updates via brew, github, git, uv, or pip."""
1
+ """Auto-update: check PyPI for a newer release, then update via brew, github, git, uv or pip."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -87,7 +87,6 @@ async def _detect_install_method() -> str:
87
87
  """Detect how the CLI was installed. Returns: brew, github, git, or pip."""
88
88
  from datalegion_cli.config import load_config
89
89
 
90
- # Check config for explicit install_method
91
90
  cfg = load_config()
92
91
  method = str(cfg.get("install_method", "")).lower()
93
92
  if method in ("brew", "github", "git", "pip"):
@@ -159,7 +158,6 @@ async def _find_release_asset(version: str | None = None) -> str | None:
159
158
  data = resp.json()
160
159
 
161
160
  assets = data.get("assets", [])
162
- # Prefer .whl, fall back to .tar.gz
163
161
  for ext in (".whl", ".tar.gz"):
164
162
  for asset in assets:
165
163
  name = asset.get("name", "")
@@ -48,7 +48,7 @@ class TestLegionClientInit:
48
48
  assert client._timeout == 10.0
49
49
 
50
50
  async def test_sends_identifying_user_agent(self):
51
- """The API's request log classifies datalegion-cli/* as CLI traffic."""
51
+ """Requests identify the CLI and its version in the User-Agent."""
52
52
  from datalegion_cli import __version__
53
53
 
54
54
  client = LegionClient(base_url="https://x.local", api_key="legion_k")
@@ -134,7 +134,6 @@ class TestRequest:
134
134
  await mock_client.close()
135
135
  mock_client._client.aclose.assert_called_once()
136
136
 
137
- # Already closed
138
137
  mock_client._client.is_closed = True
139
138
  await mock_client.close() # should not raise
140
139
 
@@ -164,11 +163,6 @@ class TestConvenienceMethods:
164
163
  await mock_client.person_search(query="SELECT * FROM people", limit=5)
165
164
  assert http.post.call_args[0][0] == "/person/search"
166
165
 
167
- # async def test_person_discover(self, mock_client, monkeypatch):
168
- # http = await self._setup_mock(mock_client, monkeypatch)
169
- # await mock_client.person_discover(query="engineers in SF")
170
- # assert http.post.call_args[0][0] == "/person/discover"
171
-
172
166
  async def test_person_bulk(self, mock_client, monkeypatch):
173
167
  http = await self._setup_mock(mock_client, monkeypatch)
174
168
  await mock_client.person_bulk(items=[{"email": "a@b.com"}])
@@ -184,11 +178,6 @@ class TestConvenienceMethods:
184
178
  await mock_client.company_search(query="SELECT * FROM companies", limit=5)
185
179
  assert http.post.call_args[0][0] == "/company/search"
186
180
 
187
- # async def test_company_discover(self, mock_client, monkeypatch):
188
- # http = await self._setup_mock(mock_client, monkeypatch)
189
- # await mock_client.company_discover(query="AI startups")
190
- # assert http.post.call_args[0][0] == "/company/discover"
191
-
192
181
  async def test_company_bulk(self, mock_client, monkeypatch):
193
182
  http = await self._setup_mock(mock_client, monkeypatch)
194
183
  await mock_client.company_bulk(items=[{"domain": "x.com"}])
@@ -14,9 +14,6 @@ from tests.conftest import make_response
14
14
  runner = CliRunner()
15
15
 
16
16
 
17
- # ── Helper ───────────────────────────────────────────────────────────
18
-
19
-
20
17
  def _mock_client_request(response_json, status_code=200, headers=None):
21
18
  """Patch LegionClient to return a canned response without HTTP."""
22
19
  hdrs = headers or {"Credits-Used": "1", "Credits-Remaining": "99"}
@@ -48,9 +45,6 @@ def _mock_config(monkeypatch):
48
45
  monkeypatch.setenv("LEGION_API_URL", "https://test.api.local")
49
46
 
50
47
 
51
- # ── Top-level commands ───────────────────────────────────────────────
52
-
53
-
54
48
  class TestVersionCommand:
55
49
  def test_version_output(self):
56
50
  result = runner.invoke(app, ["version"])
@@ -68,13 +62,11 @@ class TestConfigCommand:
68
62
 
69
63
  def test_config_set_and_get(self, tmp_config_dir, monkeypatch):
70
64
  monkeypatch.delenv("LEGION_API_KEY", raising=False)
71
- # Set
72
65
  result = runner.invoke(app, ["config", "set", "api_key", "legion_testval123"])
73
66
  assert result.exit_code == 0
74
67
  data = json.loads(result.stdout)
75
68
  assert data["ok"] is True
76
69
 
77
- # Get
78
70
  result = runner.invoke(app, ["config", "get", "api_key"])
79
71
  assert result.exit_code == 0
80
72
  data = json.loads(result.stdout)
@@ -103,9 +95,6 @@ class TestConfigCommand:
103
95
  assert result.exit_code != 0
104
96
 
105
97
 
106
- # ── Person commands ──────────────────────────────────────────────────
107
-
108
-
109
98
  class TestPersonEnrich:
110
99
  def test_enrich_by_email(self, monkeypatch):
111
100
  _mock_config(monkeypatch)
@@ -307,29 +296,6 @@ class TestPersonDiscover:
307
296
  assert data["total"] == 1
308
297
 
309
298
 
310
- # TODO: Uncomment when bulk enrichment is ready
311
- # class TestPersonBulk:
312
- # def test_bulk_from_stdin(self, monkeypatch):
313
- # _mock_config(monkeypatch)
314
- # response = {"results": [{"matches": [{"full_name": "A"}], "total": 1}]}
315
- # payload = json.dumps([{"email": "a@b.com"}])
316
- # with _mock_client_request(response):
317
- # result = runner.invoke(app, ["person", "bulk", "-"], input=payload)
318
- # assert result.exit_code == 0
319
- #
320
- # def test_bulk_from_file(self, monkeypatch, tmp_path):
321
- # _mock_config(monkeypatch)
322
- # response = {"results": []}
323
- # f = tmp_path / "items.json"
324
- # f.write_text(json.dumps({"items": [{"email": "x@y.com"}]}))
325
- # with _mock_client_request(response):
326
- # result = runner.invoke(app, ["person", "bulk", str(f)])
327
- # assert result.exit_code == 0
328
-
329
-
330
- # ── Company commands ─────────────────────────────────────────────────
331
-
332
-
333
299
  class TestCompanyEnrich:
334
300
  def test_enrich_by_domain(self, monkeypatch):
335
301
  _mock_config(monkeypatch)
@@ -382,19 +348,6 @@ class TestCompanyDiscover:
382
348
  assert result.exit_code == 0
383
349
 
384
350
 
385
- # TODO: Uncomment when bulk enrichment is ready
386
- # class TestCompanyBulk:
387
- # def test_bulk_from_stdin(self, monkeypatch):
388
- # _mock_config(monkeypatch)
389
- # response = {"results": []}
390
- # with _mock_client_request(response):
391
- # result = runner.invoke(app, ["company", "bulk", "-"], input=json.dumps([{"domain": "x.com"}]))
392
- # assert result.exit_code == 0
393
-
394
-
395
- # ── Utility commands ─────────────────────────────────────────────────
396
-
397
-
398
351
  class TestUtilityClean:
399
352
  def test_clean_from_argument(self, monkeypatch):
400
353
  _mock_config(monkeypatch)
@@ -519,9 +472,6 @@ class TestUtilityValidate:
519
472
  assert result.exit_code == 0
520
473
 
521
474
 
522
- # ── Credits commands ─────────────────────────────────────────────────
523
-
524
-
525
475
  class TestCreditsBalance:
526
476
  def test_balance(self, monkeypatch):
527
477
  _mock_config(monkeypatch)
@@ -559,9 +509,7 @@ class TestCreditsUsage:
559
509
  assert result.exit_code == 0
560
510
 
561
511
 
562
- # ── Several matches per lookup is an enterprise feature: no CLI option ──
563
-
564
-
512
+ # Several matches per lookup is an enterprise feature: no CLI option
565
513
  class TestEnrichOffersNoMultipleResults:
566
514
  def test_enrich_rejects_multiple_and_limit(self, monkeypatch):
567
515
  _mock_config(monkeypatch)
File without changes