From bf1d81aaccc3aa0480106efa03e6774e9958c657 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 15 Feb 2022 19:06:45 +1000 Subject: [PATCH] fix cyclic import when importing anki.collection directly Could be triggered with: PYTHONPATH=.bazel/bin/qt/runanki.runfiles/ankidesktop/pylib python -c 'import anki.collection' --- pylib/anki/dbproxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pylib/anki/dbproxy.py b/pylib/anki/dbproxy.py index 06f01739a..39f1ab4c6 100644 --- a/pylib/anki/dbproxy.py +++ b/pylib/anki/dbproxy.py @@ -5,9 +5,10 @@ from __future__ import annotations import re from re import Match -from typing import Any, Iterable, Sequence, Union +from typing import TYPE_CHECKING, Any, Iterable, Sequence, Union -import anki._backend +if TYPE_CHECKING: + import anki._backend # DBValue is actually Union[str, int, float, None], but if defined # that way, every call site needs to do a type check prior to using