Skip to content

typing

Module contains custom type defintions that arc uses

CommandCallback = t.Union[FunctionCallback, type[ClassCallback]] module-attribute

The type of a command's callback.

May be a function

@arc.command
def command(name: str):
    print(f"Hello {name}!")

Or a class

@arc.command
class command:
    name: str

    def handle(self):
        print(f"Hello {self.name}!")

CompletionProtocol

Bases: t.Protocol

Protocal that objects need to implement if they are expected to provide completions

Source code in /home/runner/work/arc/arc/arc/typing.py
class CompletionProtocol(t.Protocol):
    """Protocal that objects need to implement if they are expected to provide completions"""

    def __completions__(
        self,
        info: CompletionInfo,
    ) -> t.Iterable[Completion] | None:
        ...

TypeProtocol

Bases: t.Protocol

Protocol that custom types need to conform to

Source code in /home/runner/work/arc/arc/arc/typing.py
@t.runtime_checkable
class TypeProtocol(t.Protocol):
    """Protocol that custom types need to conform to"""

    @classmethod
    def __convert__(cls, value: t.Any, *args: t.Any) -> t.Any:
        ...