chore: review nits

This commit is contained in:
Benjamin McCormick 2026-02-06 14:31:03 -05:00
parent d6e5203e41
commit 8ef77d96ef
5 changed files with 23 additions and 5 deletions

View File

@ -605,7 +605,6 @@ class PeerAio(AsyncMetadataConfigMixin):
response = PeerCardResponse.model_validate(data)
return response.peer_card
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
async def card(
self,
target: str | PeerBase | None = None,
@ -625,7 +624,20 @@ class PeerAio(AsyncMetadataConfigMixin):
peer_card: list[str],
target: str | PeerBase | None = None,
) -> list[str] | None:
"""Set the peer card asynchronously."""
"""
Set the peer card for this peer.
Makes an API call to set the peer card. If a target is provided, sets this
peer's local card of the target peer.
Args:
peer_card: A list of strings to set as the peer card.
target: Optional target peer for local card. If provided, sets this
peer's card of the target peer. Can be a Peer object or peer ID string.
Returns:
A list of strings representing the updated peer card, or None if none is available
"""
await self._peer._honcho._ensure_workspace_async()
target_id = resolve_id(target)

View File

@ -477,7 +477,6 @@ class Peer(PeerBase, MetadataConfigMixin):
return response.peer_card
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def card(
self,
target: str | PeerBase | None = None,

View File

@ -28,6 +28,7 @@ import {
MessageConfigurationSchema,
MessageContentSchema,
MessageMetadataSchema,
PeerCardContentSchema,
type PeerConfig,
PeerConfigSchema,
PeerGetRepresentationParamsSchema,
@ -697,9 +698,10 @@ export class Peer {
peerCard: string[],
target?: string | Peer
): Promise<string[] | null> {
const validatedPeerCard = PeerCardContentSchema.parse(peerCard)
const validatedTarget = CardTargetSchema.parse(target)
const response = await this._setCard({
peer_card: peerCard,
peer_card: validatedPeerCard,
target: validatedTarget,
})
return response.peer_card

View File

@ -376,6 +376,11 @@ export const CardTargetSchema = z
val ? (typeof val === 'string' ? val : val.id) : undefined
)
/**
* Schema for peer card content (array of strings).
*/
export const PeerCardContentSchema = z.array(z.string())
/**
* Schema for peer addition to session.
*/

View File

@ -53,7 +53,7 @@ async def test_peer_card_get_set_roundtrip(
async def test_get_peer_card_missing_peer_returns_none(
db_session: AsyncSession, sample_data: tuple[models.Workspace, models.Peer]
):
"""Getting a peer card for a non-existent peer should return None."""
"""Getting a peer card for a non-existent peer should return None while creating the peer."""
workspace, _existing_peer = sample_data
result = await get_peer_card(
db_session,