Protocols
class
Converter (Protocol)
¶
A protocol representing a class used to convert an argument.
Source code in naff/models/naff/protocols.py
@typing.runtime_checkable
class Converter(Protocol[T_co]):
"""A protocol representing a class used to convert an argument."""
async def convert(self, ctx: "Context", argument: Any) -> T_co:
"""
The function that converts an argument to the appropriate type.
This should be overridden by subclasses for their conversion logic.
Args:
ctx: The context to use for the conversion.
argument: The argument to be converted.
Returns:
Any: The converted argument.
"""
raise NotImplementedError("Derived classes need to implement this.")
async
method
convert(self, ctx, argument)
¶
The function that converts an argument to the appropriate type.
This should be overridden by subclasses for their conversion logic.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ctx |
Context |
The context to use for the conversion. |
required |
argument |
Any |
The argument to be converted. |
required |
Returns:
Type | Description |
---|---|
Any |
The converted argument. |
Source code in naff/models/naff/protocols.py
async def convert(self, ctx: "Context", argument: Any) -> T_co:
"""
The function that converts an argument to the appropriate type.
This should be overridden by subclasses for their conversion logic.
Args:
ctx: The context to use for the conversion.
argument: The argument to be converted.
Returns:
Any: The converted argument.
"""
raise NotImplementedError("Derived classes need to implement this.")