Skip to content

Commit

Permalink
Fix covariance issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed May 3, 2024
1 parent d9554ac commit 7471da1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion aiostream/aiter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def assert_async_iterator(obj: object) -> None:

# Async iterator context

T = TypeVar("T")
T = TypeVar("T", covariant=True)
Self = TypeVar("Self", bound="AsyncIteratorContext[Any]")


Expand Down
2 changes: 1 addition & 1 deletion aiostream/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class StreamEmpty(Exception):

# Helpers

T = TypeVar("T")
T = TypeVar("T", covariant=True)
X = TypeVar("X")
A = TypeVar("A", contravariant=True)
P = ParamSpec("P")
Expand Down
5 changes: 1 addition & 4 deletions tests/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ def target2(x: int, *_) -> Stream[int]:
return stream.range(x, x + 4, interval=1)

def target3(x: int, *_) -> Stream[int]:
# TODO: fix covariance issue
return (
stream.range(0, 3, interval=1) if x else stream.throw(ZeroDivisionError)
) # type: ignore
return stream.range(0, 3, interval=1) if x else stream.throw(ZeroDivisionError)

# Concurrent run
with assert_cleanup() as loop:
Expand Down

0 comments on commit 7471da1

Please sign in to comment.