Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- SDK/CLI: `ExtractResult` drops `language`; the API no longer returns it from `/extract`.

## 0.6.2 (2026-10-21)

- SDK/CLI: Python 3.15 is supported and tested in CI.
Expand Down
2 changes: 1 addition & 1 deletion packages/discolike-cli/src/discolike_cli/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def format_help(self, ctx: Context, formatter: HelpFormatter) -> None:
""",
"extract": """\
Output (success, exit 0):
{"text": <string>, "language": <ISO 639-1>}
{"text": <string>}
Fetches the page live; use it to confirm a seed domain is the right company.

Common errors:
Expand Down
6 changes: 3 additions & 3 deletions packages/discolike-cli/tests/test_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,23 @@ def test_extract_hits_extract_endpoint_with_url(install_build_client: Callable[[

def handler(request: httpx2.Request) -> httpx2.Response:
captured["request"] = request
return httpx2.Response(200, json={"text": "hello", "language": "en"})
return httpx2.Response(200, json={"text": "hello"})

install_build_client(handler)
result = runner.invoke(app, ["extract", "https://acme.com/about"])
assert result.exit_code == 0, result.output
request = captured["request"]
assert request.url.path == "/v1/extract"
assert request.url.params.get("url") == "https://acme.com/about"
assert json.loads(result.stdout) == {"text": "hello", "language": "en"}
assert json.loads(result.stdout) == {"text": "hello"}


def test_extract_domain_option_replaces_url(install_build_client: Callable[[Handler], None]) -> None:
captured: dict[str, httpx2.Request] = {}

def handler(request: httpx2.Request) -> httpx2.Response:
captured["request"] = request
return httpx2.Response(200, json={"text": "hello", "language": "en"})
return httpx2.Response(200, json={"text": "hello"})

install_build_client(handler)
result = runner.invoke(app, ["extract", "--domain", "acme.com"])
Expand Down
1 change: 0 additions & 1 deletion packages/discolike/src/discolike/resources/companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class Growth(DiscolikeModel):

class ExtractResult(DiscolikeModel):
text: str | None = None
language: str | None = None


class Redirect(DiscolikeModel):
Expand Down
3 changes: 1 addition & 2 deletions packages/discolike/tests/test_companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,12 @@ def handler(request: httpx2.Request) -> httpx2.Response:

def test_extract_parses_text_and_language(make_client: ClientFactory) -> None:
def handler(request: httpx2.Request) -> httpx2.Response:
return httpx2.Response(200, json={"language": "en", "text": "Acme makes widgets."})
return httpx2.Response(200, json={"text": "Acme makes widgets."})

with make_client(handler) as client:
result = client.companies.extract(CompaniesExtractParams(domain="acme.com"))

assert result.text == "Acme makes widgets."
assert result.language == "en"


def test_unset_match_mode_is_not_sent(make_client: ClientFactory) -> None:
Expand Down
18 changes: 6 additions & 12 deletions packages/discolike/tests/test_contract_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,24 @@ def test_check_models_passes_when_spec_matches_model():
check_contract = _load_check_contract()
from discolike.resources.companies import ExtractResult

spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}, "language": {}}}}}}
spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}}}}}}
assert check_contract.check_models(spec, {"ExtractResponse": ExtractResult}) == []


def test_check_models_reports_field_the_spec_does_not_have():
check_contract = _load_check_contract()
from discolike.resources.companies import ExtractResult

spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}}}}}}
spec = {"components": {"schemas": {"ExtractResponse": {"properties": {}}}}}
mismatches = check_contract.check_models(spec, {"ExtractResponse": ExtractResult})
assert mismatches == ["ExtractResult: field 'language' not in spec schema 'ExtractResponse'"]
assert mismatches == ["ExtractResult: field 'text' not in spec schema 'ExtractResponse'"]


def test_check_models_reports_field_the_sdk_does_not_declare():
check_contract = _load_check_contract()
from discolike.resources.companies import ExtractResult

spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}, "language": {}, "summary": {}}}}}}
spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}, "summary": {}}}}}}
mismatches = check_contract.check_models(spec, {"ExtractResponse": ExtractResult})
assert mismatches == ["ExtractResult: spec schema 'ExtractResponse' has field 'summary' the SDK does not declare"]

Expand All @@ -92,7 +92,7 @@ def test_check_models_ignores_type_and_requiredness_when_spec_gives_no_type_info
check_contract = _load_check_contract()
from discolike.resources.companies import ExtractResult

spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}, "language": {}}}}}}
spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {}}}}}}
assert check_contract.check_models(spec, {"ExtractResponse": ExtractResult}) == []


Expand Down Expand Up @@ -143,7 +143,6 @@ def test_check_models_passes_a_nullable_field_expressed_via_anyof():
"ExtractResponse": {
"properties": {
"text": {"anyOf": [{"type": "string"}, {"type": "null"}]},
"language": {"anyOf": [{"type": "string"}, {"type": "null"}]},
},
}
}
Expand All @@ -162,7 +161,6 @@ def test_check_models_passes_a_nullable_field_expressed_via_openapi_nullable_fla
"ExtractResponse": {
"properties": {
"text": {"type": "string", "nullable": True},
"language": {"type": "string", "nullable": True},
},
}
}
Expand All @@ -185,11 +183,7 @@ def test_check_models_accepts_an_sdk_field_nullable_where_the_spec_is_not():
check_contract = _load_check_contract()
from discolike.resources.companies import ExtractResult

spec = {
"components": {
"schemas": {"ExtractResponse": {"properties": {"text": {"type": "string"}, "language": {"type": "string"}}}}
}
}
spec = {"components": {"schemas": {"ExtractResponse": {"properties": {"text": {"type": "string"}}}}}}
assert check_contract.check_models(spec, {"ExtractResponse": ExtractResult}) == []


Expand Down
Loading