1.7.1: revert dict | Model union return types from 1.7.0 (downstream-breaking regression)#34
Merged
jackparnell merged 1 commit intomainfrom Apr 12, 2026
Merged
Conversation
1.7.0 introduced ``dict | Post`` (and similar) return type annotations
on several read methods to advertise the new typed=True mode. This
broke every downstream consumer running strict mypy: they could no
longer call ``.get()`` on the return value because mypy couldn't
narrow the union.
This is a SemVer violation — minor versions shouldn't break things.
1.7.1 reverts the annotations to plain ``dict`` for backward
compatibility. Runtime behaviour is unchanged: typed=True still wraps
responses in dataclass models. Typed-mode users who want strict
static types should ``cast(Post, ...)`` at the call site:
from typing import cast
from colony_sdk import ColonyClient, Post
client = ColonyClient("col_...", typed=True)
post = cast(Post, client.get_post("abc"))
print(post.title)
Affected methods (sync + async):
- get_post, update_post, get_poll, send_message, get_me, get_user
- create_comment, create_webhook (async only had unions on these)
Added a regression test (TestReturnTypeAnnotations) that pins the
public method return annotations as the string literal "dict" so we
don't reintroduce the unions. 348 unit tests pass, 100% coverage,
mypy clean. Verified against the live API via integration tests
(16 v1.7.0-features tests still pass — runtime unchanged).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
1.7.0 introduced
dict | Post(and similar union) return types on several read methods to advertise the newtyped=Truemode:```python
def get_post(self, post_id: str) -> dict | Post: # 1.7.0
```
This broke every downstream consumer running strict mypy. They could no longer call `.get()` on the return value because mypy couldn't narrow the union:
```
src/langchain_colony/tools.py:223: error: Item "Post" of "dict[Any, Any] | Post" has no attribute "get" [union-attr]
```
Discovered while migrating smolagents-colony to colony-sdk 1.7.0 — got 77 mypy errors purely from the SDK type annotation change.
This is a SemVer violation: 1.6.0 → 1.7.0 was a minor bump but it broke type checking for every framework integration that uses the SDK with strict mypy.
The fix
Reverted the union return types to plain `dict` for backward compatibility. Runtime behaviour is unchanged — `typed=True` still wraps responses in the dataclass models at runtime; only the static type hints changed.
Typed-mode users who want strict static types should `cast(Post, ...)` at the call site:
```python
from typing import cast
from colony_sdk import ColonyClient, Post
client = ColonyClient("col_...", typed=True)
post = cast(Post, client.get_post("abc"))
print(post.title) # mypy now knows this is a Post
```
Affected methods
Sync + async:
Regression test
Added `TestReturnTypeAnnotations` in `tests/test_client.py` that pins the public method return annotations as the string literal `"dict"`. Anyone reintroducing the unions will get a clear failure.
Validation
Why this is a patch (not a minor)
No new features. No behaviour changes. Just fixing a SemVer-violating regression from 1.7.0. Once this lands and tags as v1.7.1, downstream framework repos can drop their workarounds (e.g. the per-module mypy override I had to add to smolagents-colony).
🤖 Generated with Claude Code