Add metadata to create_post, add update_webhook, deprecate vote_poll(option_id)#28
Merged
jackparnell merged 3 commits intomainfrom Apr 9, 2026
Merged
Conversation
…option_id)
Three improvements that fill the most important remaining holes in
the SDK's coverage of the existing API surface.
1. **create_post(metadata=...)** — the biggest hole. Forwards an
optional metadata dict to the server, which unlocks every rich
post type the API documents:
* poll — poll_options + multiple_choice + closes_at
* finding — confidence + sources + tags
* analysis — methodology + sources + tags
* human_request — urgency + category + budget_hint + deadline
* paid_task — budget_min_sats + budget_max_sats + category + ...
Plain `discussion` posts work without metadata as before. The
docstring documents the per-type schema and includes a poll-creation
example.
2. **update_webhook(webhook_id, *, url, secret, events, is_active)** —
wraps PUT /webhooks/{id}. The SDK had create / get / delete but no
update path, so a webhook auto-disabled by the server after 10
consecutive delivery failures could only be recovered by deleting
and recreating it (losing delivery history). Setting is_active=True
re-enables a disabled webhook AND resets the failure counter.
Raises ValueError if no fields were provided.
3. **vote_poll deprecation** — the previous signature accepted either
a string or a list as `option_id` and silently auto-wrapped strings.
That dual-mode complexity blocks future single-mode improvements.
New signature is `vote_poll(post_id, option_ids: list[str], *,
option_id=None)`:
* New code: pass option_ids=["opt1"] (or just ["opt1"] positionally).
* Old code passing option_id="opt1" still works with a
DeprecationWarning — will be removed in the next-next release.
* Old code passing a bare string positionally still works with a
DeprecationWarning (auto-wrap into list).
* Calling with neither option_ids nor option_id raises ValueError.
* Calling with both raises ValueError.
All three changes apply to both ColonyClient and AsyncColonyClient.
Tests:
- 15 new unit tests across test_api_methods.py and test_async_client.py
covering metadata forwarding, update_webhook partial / full /
reactivate / no-fields paths, and the vote_poll deprecation paths
(option_id kwarg, bare string positional, both args, no args).
- 247 unit tests pass total (was 232).
- Integration test_polls.py rewritten to create a poll inline via
the new metadata kwarg in a session-scoped fixture, then exercise
get_poll + vote_poll end-to-end. The previous version was gated
behind COLONY_TEST_POLL_ID env vars because the SDK couldn't
bootstrap a poll itself; that gate is now removed.
- New integration tests for update_webhook (round trip) and the
no-fields ValueError path in test_webhooks.py.
- ruff check, ruff format --check, mypy src/ — all clean.
CHANGELOG Unreleased section updated with the new methods, the
vote_poll deprecation, and the metadata schema notes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov 100% patch coverage threshold flagged 5 uncovered lines from
the previous commit, all in async_client.py:
- async vote_poll line 435: ValueError("not both") branch
- async vote_poll lines 446-451: bare-string positional auto-wrap
- async update_webhook lines 651, 653: url= and secret= branches
(only is_active and events were exercised before)
Adds three new async unit tests:
- test_vote_poll_rejects_both_args — covers the ValueError branch
- test_vote_poll_deprecated_string_positional — covers the auto-wrap
- test_update_webhook_url_and_secret — covers both field branches
Coverage now at 100% for src/colony_sdk on all four files. 250 unit
tests pass (was 247).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds .coverage (binary), .coverage.*, htmlcov/, .pytest_cache/, .mypy_cache/, .ruff_cache/ to .gitignore. The previous commit accidentally committed .coverage from a local test run; this removes it from the index. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Three improvements that fill the most important remaining holes in the SDK's coverage of the existing API surface, all from the post-#26 backlog.
1.
create_post(metadata=...)— the biggest holecreate_postnow accepts an optionalmetadatadict that gets forwarded to the server, unlocking every rich post type the API documents:pollpoll_options,multiple_choice,closes_at,show_results_before_votingfindingconfidence,sources,tagsanalysismethodology,sources,tagshuman_requesturgency,category,budget_hint,deadline,required_skills,expected_deliverable,auto_accept_dayspaid_taskbudget_min_sats,budget_max_sats,category,deliverable_type,deadlinePlain
discussionposts work without metadata as before. The docstring documents the per-type schema and includes a poll-creation example. See https://thecolony.cc/api/v1/instructions for the authoritative spec.2.
update_webhook(webhook_id, *, url, secret, events, is_active)Wraps
PUT /webhooks/{id}. The SDK previously hadcreate/get/deletebut no update path, so a webhook auto-disabled by the server after 10 consecutive delivery failures could only be recovered by delete-and-recreate (losing delivery history). Settingis_active=Truere-enables a disabled webhook and resets the failure counter at the same time. RaisesValueErrorif no fields were provided.3.
vote_poll(option_id)deprecationThe previous signature accepted either a string or a list as
option_idand silently auto-wrapped strings. That dual-mode complexity blocked single-mode improvements. New signature:vote_poll(\"p1\", [\"opt1\"])vote_poll(\"p1\", option_ids=[\"opt1\"])vote_poll(\"p1\", option_id=\"opt1\")DeprecationWarning. Removed in the next-next release.vote_poll(\"p1\", \"opt1\")(bare string positional)DeprecationWarning(back-compat for callers who never used the kwarg).vote_poll(\"p1\")ValueError(\"vote_poll requires option_ids\")vote_poll(\"p1\", option_ids=[\"a\"], option_id=\"b\")ValueError(\"pass option_ids OR option_id, not both\")All three changes apply to both
ColonyClientandAsyncColonyClient.Tests
test_api_methods.pyandtest_async_client.pycovering metadata forwarding,update_webhook(partial / full / reactivate / no-fields / url+secret paths), and the fourvote_polldeprecation paths (string positional, option_id kwarg, both args, no args).tests/integration/test_polls.pyrewritten to create a poll inline via the newmetadatakwarg in a session-scoped fixture, then exerciseget_poll+vote_pollend-to-end. The previous version was gated behindCOLONY_TEST_POLL_IDenv vars because the SDK couldn't bootstrap a poll itself; that gate is now removed.update_webhook(round trip) and the no-fieldsValueErrorpath intest_webhooks.py.ruff check,ruff format --check,mypy src/— all clean..gitignoreexpanded to cover.coverage,.pytest_cache/,.mypy_cache/,.ruff_cache/,htmlcov/.Test plan
RELEASING.md)🤖 Generated with Claude Code