Skip to content

Commit 3639633

Browse files
bokelleyclaude
andcommitted
fix: use collections.abc.Callable and shorten line length
Addresses ruff linter errors: - Import Callable from collections.abc instead of typing (UP035) - Create MessageFormatter type alias to shorten line length (E501) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 928e7ba commit 3639633

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/adcp/types/base.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
"""Base model for AdCP types with spec-compliant serialization."""
44

5-
from typing import Any, Callable
5+
from collections.abc import Callable
6+
from typing import Any
67

78
from pydantic import BaseModel
89

10+
# Type alias to shorten long type annotations
11+
MessageFormatter = Callable[[Any], str]
12+
913

1014
def _pluralize(count: int, singular: str, plural: str | None = None) -> str:
1115
"""Return singular or plural form based on count."""
@@ -16,13 +20,13 @@ def _pluralize(count: int, singular: str, plural: str | None = None) -> str:
1620

1721
# Registry of human-readable message formatters for response types.
1822
# Key is the class name, value is a callable that takes the instance and returns a message.
19-
_RESPONSE_MESSAGE_REGISTRY: dict[str, Callable[[Any], str]] = {}
23+
_RESPONSE_MESSAGE_REGISTRY: dict[str, MessageFormatter] = {}
2024

2125

22-
def _register_response_message(cls_name: str) -> Callable[[Callable[[Any], str]], Callable[[Any], str]]:
26+
def _register_response_message(cls_name: str) -> Callable[[MessageFormatter], MessageFormatter]:
2327
"""Decorator to register a message formatter for a response type."""
2428

25-
def decorator(func: Callable[[Any], str]) -> Callable[[Any], str]:
29+
def decorator(func: MessageFormatter) -> MessageFormatter:
2630
_RESPONSE_MESSAGE_REGISTRY[cls_name] = func
2731
return func
2832

0 commit comments

Comments
 (0)