mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-26 21:14:19 +00:00
🔧 Rename teleporter function to teleport
To avoid name conflicts
This commit is contained in:
parent
d5d502188a
commit
7af7ebc860
3 changed files with 10 additions and 10 deletions
|
@ -72,7 +72,7 @@ class Command:
|
|||
text: str = await _msg.text()
|
||||
match: re.Match = self.pattern.search(text)
|
||||
match_kwargs: dict = match.groupdict()
|
||||
teleported: t.Callable = teleporter.teleporter(is_async=True, validate_output=False)(f)
|
||||
teleported: t.Callable = teleporter.teleport(is_async=True, validate_output=False)(f)
|
||||
return await teleported(_msg=_msg, **original_kwargs, **match_kwargs)
|
||||
return decorated
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ def teleport_out(__model: type, value: Value) -> Value:
|
|||
raise exc.OutTeleporterError(errors=e.raw_errors, model=e.model)
|
||||
|
||||
|
||||
def teleporter(__config__: t.Type[pydantic.BaseConfig] = TeleporterConfig,
|
||||
def teleport(__config__: t.Type[pydantic.BaseConfig] = TeleporterConfig,
|
||||
is_async: bool = False,
|
||||
validate_input: bool = True,
|
||||
validate_output: bool = True):
|
||||
|
@ -188,5 +188,5 @@ def teleporter(__config__: t.Type[pydantic.BaseConfig] = TeleporterConfig,
|
|||
|
||||
__all__ = (
|
||||
"TeleporterConfig",
|
||||
"teleporter",
|
||||
"teleport",
|
||||
)
|
||||
|
|
|
@ -59,7 +59,7 @@ def test_signature_to_model(my_function):
|
|||
# noinspection PyTypeChecker
|
||||
class TestTeleporter:
|
||||
def test_standard_function(self):
|
||||
@tp.teleporter()
|
||||
@tp.teleport()
|
||||
def standard_function(a: int, b: int, _return_str: bool = False) -> int:
|
||||
if _return_str:
|
||||
return "You asked me this."
|
||||
|
@ -92,7 +92,7 @@ class TestTeleporter:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_async_function(self):
|
||||
@tp.teleporter(is_async=True)
|
||||
@tp.teleport(is_async=True)
|
||||
async def async_function(a: int, b: int, _return_str: bool = False) -> int:
|
||||
if _return_str:
|
||||
return "You asked me this."
|
||||
|
@ -124,7 +124,7 @@ class TestTeleporter:
|
|||
_ = await async_function(1, 2)
|
||||
|
||||
def test_only_input(self):
|
||||
@tp.teleporter(validate_output=False)
|
||||
@tp.teleport(validate_output=False)
|
||||
def standard_function(a: int, b: int, _return_str: bool = False) -> int:
|
||||
if _return_str:
|
||||
return "You asked me this."
|
||||
|
@ -155,7 +155,7 @@ class TestTeleporter:
|
|||
_ = standard_function(1, 2)
|
||||
|
||||
def test_only_output(self):
|
||||
@tp.teleporter(validate_input=False)
|
||||
@tp.teleport(validate_input=False)
|
||||
def standard_function(a: int, b: int, _return_str: bool = False) -> int:
|
||||
if _return_str:
|
||||
return "You asked me this."
|
||||
|
|
Loading…
Reference in a new issue