beanie
beanie copied to clipboard
[BUG] Multi-model pattern
Describe the bug
"Never" is not awaitablePylancereportGeneralTypeIssues Could not bind method "find" because "type[Parent]" is not assignable to parameter "cls" Type "Parent" cannot be assigned to type "Document" "Parent" is incompatible with "Document"PylancereportGeneralTypeIssues (method) find: Never
"Never" is not awaitablePylancereportGeneralTypeIssues (function) to_list: Never
To Reproduce
from beanie import Document, UnionDoc
class Parent(UnionDoc): # Union
class Settings:
name = "union_doc_collection" # Collection name
class_id = "_class_id" # _class_id is default beanie internal field used to filter children Documents
class One(Document):
int_field: int = 0
shared: int = 0
class Settings:
name = "One" # Name used to filer union document 'One', default to class name
union_doc = Parent
class Two(Document):
str_field: str = "test"
shared: int = 0
class Settings:
union_doc = Parent
async def example():
db = AsyncIOMotorClient(config._DB_CONNECT, compressors='zstd', tz_aware=True).LOTR
await init_beanie(database=db, document_models=[Parent, One, Two]) # type: ignore
data = await Parent.find().to_list()
if __name__ == "__main__":
asyncio.run(example())
Expected behavior This bug is very annoying I expect it display a list of Parent but instead its unknown and full of error Im expecting it display data: list[Parent] = await Parent.all().to_list() # type: ignore
Additional context
This issue is stale because it has been open 30 days with no activity.
Hi @CAPITAINMARVEL , thank you for the catch. Sorry for the delay, it was a crazy end of the year for me. May I ask, why did you close the PRs? They are not working properly?