Convert the cursor to a list.
(self, length: Optional[int] = None)
| 1971 | return GridOut(self._root_collection, file_document=next_file, session=self.session) |
| 1972 | |
| 1973 | def to_list(self, length: Optional[int] = None) -> list[GridOut]: |
| 1974 | """Convert the cursor to a list.""" |
| 1975 | if length is None: |
| 1976 | return [x for x in self] # noqa: C416,RUF100 |
| 1977 | if length < 1: |
| 1978 | raise ValueError("to_list() length must be greater than 0") |
| 1979 | ret = [] |
| 1980 | for _ in range(length): |
| 1981 | ret.append(self.next()) |
| 1982 | return ret |
| 1983 | |
| 1984 | __next__ = next |
| 1985 |