File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,17 @@ def __repr__(self) -> str:
119119 return f"<{ self .__class__ .__name__ } of { self ._iterator !r} at 0x{ (id (self )):x} >"
120120
121121
122- def borrow (iterator : AsyncIterator [T ], / ) -> AsyncIterator [T ]:
122+ @overload
123+ def borrow (iterator : AsyncGenerator [T , S ], / ) -> AsyncGenerator [T , S ]: ...
124+
125+
126+ @overload
127+ def borrow (iterator : AsyncIterator [T ], / ) -> AsyncIterator [T ]: ...
128+
129+
130+ def borrow (
131+ iterator : Union [AsyncIterator [T ], AsyncGenerator [T , Any ]], /
132+ ) -> Union [AsyncIterator [T ], AsyncGenerator [T , Any ]]:
123133 """
124134 Borrow an async iterator, preventing to ``aclose`` it
125135
@@ -142,7 +152,7 @@ def borrow(iterator: AsyncIterator[T], /) -> AsyncIterator[T]:
142152 "borrowing requires an async iterator "
143153 + f"with __aiter__ and __anext__ method, got { type (iterator ).__name__ } "
144154 )
145- return _BorrowedAsyncIterator (iterator )
155+ return _BorrowedAsyncIterator [ T , Any ] (iterator )
146156
147157
148158def scoped_iter (iterable : AnyIterable [T ], / ) -> AsyncContextManager [AsyncIterator [T ]]:
You can’t perform that action at this time.
0 commit comments