From 55df41668e72e49ac3d5fbd084ccef2540b3ce14 Mon Sep 17 00:00:00 2001 From: TARS Date: Sat, 17 Oct 2026 04:38:27 +0000 Subject: [PATCH] docs(readme): narrow ContentBlockedError.result in the intro LangChain example 0.5.0 widened ContentBlockedError.result to ScanResult | None (None only with fail_closed=True). The introductory example read error.result.firewall directly, which fails mypy with union-attr. Narrow it the same way the later README example does. Found by independent release review of #11 (nit N1). --- CHANGELOG.md | 6 ++++++ README.md | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74438d..daa2962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +### Documentation + +- README: the introductory LangChain example now narrows + `ContentBlockedError.result` before reading `.firewall`, matching the + `ScanResult | None` annotation added in 0.5.0, so it passes type checking. + ## 0.5.0 — 2026-10-17 Minor release: opt-in fail-closed and QUARANTINE blocking for the LangChain diff --git a/README.md b/README.md index 91569e5..17652c8 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,8 @@ async with AsyncShieldCortex(api_key="sc_live_...") as client: try: reply = await model.ainvoke("Hello", config={"callbacks": [handler]}) except ContentBlockedError as error: # also a ValueError - print(error.result.firewall.reason, error.source_identifier) + if error.result is not None: # None only with fail_closed=True + print(error.result.firewall.reason, error.source_identifier) with ShieldCortex(api_key="sc_live_...") as client: handler = ShieldCortexSyncCallbackHandler(client, raise_on_block=True)