Skip to content

fix: Raise DefinitionError for tags given as a string - #213

Merged
slatecipher merged 2 commits into
mainlinefrom
fix/tags-sequence
Dec 4, 2026
Merged

slatecipher merged 2 commits into
mainlinefrom
fix/tags-sequence

Conversation

@slatecipher

Copy link
Copy Markdown
Owner

What and why

A string is a sequence of strings, so tags="users" passed the type check and made each character a tag (["u", "s", "e", "r", "s"]). Also, the verb decorators and @tool typed tags= as list[str], so type checkers rejected a tuple that a resource's tags= accepts.

  • tags= given as a string raises DefinitionError on a resource, a verb decorator or @tool, with the list to write instead. The three share one check, checked_tags in _endpoint.py.
  • The verb decorators' and @tool's tags= are typed Sequence[str], as on Resource and AsyncResource. Both already copied the tags into a list, so nothing changes at runtime.
  • The reference page and the changelog (### Fixed) are updated.

Testing

  • make check passes: lint, type checks, and 391 tests with the coverage gate.
  • A new test in test_clients.py checks the DefinitionError on a resource, a verb decorator and @tool.
  • The typing contract passes tuple tags, checked by pyright and mypy.

🤖 Generated with Claude Code

slatecipher and others added 2 commits December 3, 2026 13:17
- Annotate tags= on the verb decorators and @tool as Sequence[str],
  as on Resource and AsyncResource, so type checkers accept a tuple.
- Both already copy the tags into a list, so nothing changes at runtime.
- Pass tuple tags in the typing contract, checked by pyright and mypy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A string is a sequence of strings, so tags="users" passed the type
  check and made each character a tag. Raise DefinitionError for one on
  a resource, a verb decorator or @tool, with the list to write instead.
- Share the check, checked_tags in _endpoint.py, between the three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@slatecipher slatecipher added the bug Something isn't working label Dec 4, 2026
@slatecipher slatecipher self-assigned this Dec 4, 2026
@slatecipher
slatecipher merged commit 32b6b0d into mainline Dec 4, 2026
8 checks passed
@slatecipher
slatecipher deleted the fix/tags-sequence branch December 4, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant