The TinyDB forum is finding a new at GitHub discussions. Although the content here will remain as an archive, the forum will be put into read-only mode in the next weeks.
from docs
all() → List[tinydb.table.Document] Get all documents stored in the table.
but when I look at the source
def all(self) -> List[Document]:
and
class Document(dict):
should the return type for all() be a type from typing
all()
typing
ie:
all() → List[Dict]
as I said in title confused
Hey kevindawson, the return type is a MyPy type annotation that says that all() will return a list of documents. So List just tells that we're returning a list object which is what the docs show.
list
List
msiemens, thank you for the reply still confused though
tinydb.table.Document is not inMyPy but List is.
tinydb.table.Document
MyPy
Is it still valid
or can you only use MyPy types
kevindawson Is it still valid or can you only use MyPy types
kevindawson Is it still valid
No, you can use your own types/classes too with MyPy. Otherwise one would't be able to describe a list of objects of a custom class which is a normal thing to do in Python.