pass weakref in from storage to fix type checking/code completion
This commit is contained in:
parent
db1508e27c
commit
63e3357068
@ -3,7 +3,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import weakref
|
||||
from typing import Any, Iterable, List, Optional, Sequence, Union
|
||||
|
||||
import anki
|
||||
@ -28,7 +27,7 @@ class DBProxy:
|
||||
###############
|
||||
|
||||
def __init__(self, backend: anki.rsbackend.RustBackend, path: str) -> None:
|
||||
self._backend = weakref.proxy(backend)
|
||||
self._backend = backend
|
||||
self._path = path
|
||||
self.mod = False
|
||||
|
||||
|
@ -14,6 +14,7 @@ from typing import (
|
||||
NewType,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
@ -387,7 +388,7 @@ class RustBackend:
|
||||
self._run_command(pb.BackendInput(restore_trash=pb.Empty()))
|
||||
|
||||
def db_query(
|
||||
self, sql: str, args: List[ValueForDB], first_row_only: bool
|
||||
self, sql: str, args: Sequence[ValueForDB], first_row_only: bool
|
||||
) -> List[DBRow]:
|
||||
return self._db_command(
|
||||
dict(kind="query", sql=sql, args=args, first_row_only=first_row_only)
|
||||
|
@ -4,6 +4,7 @@
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import weakref
|
||||
from typing import Any, Dict, Optional, Tuple
|
||||
|
||||
from anki.collection import _Collection
|
||||
@ -38,7 +39,7 @@ def Collection(path: str, server: Optional[ServerData] = None) -> _Collection:
|
||||
backend = RustBackend(
|
||||
path, media_dir, media_db, log_path, server=server is not None
|
||||
)
|
||||
db = DBProxy(backend, path)
|
||||
db = DBProxy(weakref.proxy(backend), path)
|
||||
db.begin()
|
||||
db.setAutocommit(True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user