Compare commits

...

3 Commits
master ... v3.3

Author SHA1 Message Date
Steven Silvester
cbabb00550 BUMP 3.3.2.dev0 2023-08-31 15:39:18 -05:00
Steven Silvester
7ab5080b62
MOTOR-1184 Release 3.3.1 (#228) 2023-08-31 15:36:56 -05:00
Sergi
62cf1742fc MOTOR-1183 Typing issue in core.pyi causing MyPy error for to_list … (#226)
Co-authored-by: Sergi Pous <spous@objectvideo.com>
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
2023-08-31 12:27:12 -05:00
4 changed files with 11 additions and 9 deletions

View File

@ -3,6 +3,10 @@ Changelog
.. currentmodule:: motor.motor_tornado
Motor 3.3.1
-----------
- Fix a bug in the type hint for :meth:`MotorCursor.to_list`.
Motor 3.3.0
-----------

View File

@ -14,7 +14,7 @@
"""Version-related data for motor."""
version_tuple = (3, 3, 0)
version_tuple = (3, 3, 2, ".dev0")
def get_version_string() -> str:

View File

@ -16,6 +16,7 @@
from __future__ import annotations
from asyncio import Future
from typing import (
Any,
Awaitable,
@ -654,11 +655,11 @@ class AgnosticBaseCursor(AgnosticBase):
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> Any: ...
def _get_more(self) -> int: ...
@property
def fetch_next(self) -> Any: ...
def fetch_next(self) -> Future[Any]: ...
def next_object(self) -> Any: ...
def each(self, callback: Callable) -> None: ...
def _each_got_more(self, callback: Callable, future: Any) -> None: ...
def to_list(self, length: int) -> List: ...
def to_list(self, length: int) -> Future[List]: ...
def _to_list(self, length: int, the_list: List, future: Any, get_more_result: Any) -> None: ...
def get_io_loop(self) -> Any: ...
def batch_size(self, batch_size: int) -> AgnosticBaseCursor: ...

View File

@ -17,7 +17,7 @@ sample client code that uses Motor typings.
"""
import unittest
from test.asyncio_tests import AsyncIOTestCase, asyncio_test
from typing import TYPE_CHECKING, Any, AsyncIterable, Dict, List, Union
from typing import TYPE_CHECKING, Any, Dict, List, Union
from bson import CodecOptions
from bson.raw_bson import RawBSONDocument
@ -80,13 +80,10 @@ class TestMotor(AsyncIOTestCase):
self.assertEqual(result2.inserted_id, result.inserted_id)
@asyncio_test
async def test_cursor_iterable(self) -> None:
async def to_list(iterable: AsyncIterable[Dict[str, Any]]) -> List[Dict[str, Any]]:
return [gen async for gen in iterable]
async def test_cursor_to_list(self) -> None:
await self.collection.insert_one({})
cursor = self.collection.find()
docs = await to_list(cursor)
docs = await cursor.to_list(None)
self.assertTrue(docs)
@only_type_check