forked from goodboy/tractor
Fix typing
parent
7d9a551f77
commit
2905127dc7
|
@ -340,7 +340,7 @@ class Portal:
|
||||||
self,
|
self,
|
||||||
func: Callable,
|
func: Callable,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> Context:
|
) -> AsyncGenerator[Tuple[Context, Any], None]:
|
||||||
"""Open an inter-actor task context.
|
"""Open an inter-actor task context.
|
||||||
|
|
||||||
This is a synchronous API which allows for deterministic
|
This is a synchronous API which allows for deterministic
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
|
"""
|
||||||
|
Message stream types and APIs.
|
||||||
|
|
||||||
|
"""
|
||||||
import inspect
|
import inspect
|
||||||
from contextlib import contextmanager, asynccontextmanager
|
from contextlib import contextmanager, asynccontextmanager
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, Iterator, Optional, Callable
|
from typing import (
|
||||||
|
Any, Iterator, Optional, Callable,
|
||||||
|
AsyncGenerator,
|
||||||
|
)
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import trio
|
import trio
|
||||||
|
@ -288,7 +296,7 @@ class Context:
|
||||||
async def open_stream(
|
async def open_stream(
|
||||||
self,
|
self,
|
||||||
shield: bool = False,
|
shield: bool = False,
|
||||||
) -> MsgStream:
|
) -> AsyncGenerator[MsgStream, None]:
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
actor = current_actor()
|
actor = current_actor()
|
||||||
|
@ -339,7 +347,9 @@ def stream(func: Callable) -> Callable:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# annotate
|
# annotate
|
||||||
func._tractor_stream_function = True
|
# TODO: apply whatever solution ``mypy`` ends up picking for this:
|
||||||
|
# https://github.com/python/mypy/issues/2087#issuecomment-769266912
|
||||||
|
func._tractor_stream_function = True # type: ignore
|
||||||
|
|
||||||
sig = inspect.signature(func)
|
sig = inspect.signature(func)
|
||||||
params = sig.parameters
|
params = sig.parameters
|
||||||
|
@ -369,7 +379,9 @@ def context(func: Callable) -> Callable:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# annotate
|
# annotate
|
||||||
func._tractor_context_function = True
|
# TODO: apply whatever solution ``mypy`` ends up picking for this:
|
||||||
|
# https://github.com/python/mypy/issues/2087#issuecomment-769266912
|
||||||
|
func._tractor_context_function = True # type: ignore
|
||||||
|
|
||||||
sig = inspect.signature(func)
|
sig = inspect.signature(func)
|
||||||
params = sig.parameters
|
params = sig.parameters
|
||||||
|
|
Loading…
Reference in New Issue