(2.1.49) ImportError when importing hooks submodule

I’m following the Anki guide for add-on development, and have installed aqt==2.1.49 (bringing with it anki==2.1.49) into a python3.9 virtual environment. When I try to import the hooks submodule, I get an ImportError exception:

>>> from anki import hooks
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/hooks.py", line 20, in <module>
    from anki.hooks_gen import *
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/hooks_gen.py", line 14, in <module>
    from anki.cards import Card
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/cards.py", line 15, in <module>
    from anki.consts import *
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/consts.py", line 94, in <module>
    import anki.collection
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/collection.py", line 44, in <module>
    import anki.latex
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/latex.py", line 15, in <module>
    from anki.template import TemplateRenderContext, TemplateRenderOutput
  File "/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/template.py", line 36, in <module>
    from anki.cards import Card
ImportError: cannot import name 'Card' from partially initialized module 'anki.cards' (most likely due to a circular import) (/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/cards.py)

Downgrading to aqt==2.1.44 solves this problem.

>>> from anki import hooks
>>> hooks.anki
<module 'anki' from '/home/daniel/Projects/dummy-anki-addon/venv/lib/python3.9/site-packages/anki/__init__.py'>

2.1.44 is the latest version of aqt/anki that does not exhibit this import problem; the problem shows up in 2.1.45 and after.

My python3 version:

$ python3 --version
Python 3.9.2

Issue was reported to Github (ankitects/anki#1531; can’t link to the issue) and I apparently missed it. Dae has responded. It is curious that this issue appears in 2.1.45 and later, though.

Recent versions require you to import anki.collection first to avoid a circular import, but this is not required when running as an add-on.