<p dir="auto"><strong>Migrated issue, originally created by Daniel Kassen</strong></p>
<p dir="auto">Below is a snippet of code that defines a Parent class and a Child class which is abstract and used for inheritance. Classes that inherit from Child do not automatically populate if the entry exists in the database. By that, I mean the proper query is not performed to automatically pull that object out from the database even though it exists, causing duplicate entry errors when commit()'ing the session.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class Parent(Base):
    __tablename__ = 'parent'

    id = Column(Integer, primary_key=true)
    name = Column(String(100, collation='utf8_bin'),
                  nullable=False, unique=True)


class Child(Base):
        __abstract__ = True

        @classmethod
        def _classname(cls):
            return cls.__name__

        @delcared_attr
        def __tablename__(self):
            return self._classname().lower()
        
        @delcared_attr
        def id(self):
            return Column(Integer, ForeignKey(Parent.id), primary_key=True)

        @declared_attr
        def parent(self):
            return relationship(Parent)"><pre class="notranslate"><code class="notranslate">class Parent(Base):
    __tablename__ = 'parent'

    id = Column(Integer, primary_key=true)
    name = Column(String(100, collation='utf8_bin'),
                  nullable=False, unique=True)


class Child(Base):
        __abstract__ = True

        @classmethod
        def _classname(cls):
            return cls.__name__

        @delcared_attr
        def __tablename__(self):
            return self._classname().lower()
        
        @delcared_attr
        def id(self):
            return Column(Integer, ForeignKey(Parent.id), primary_key=True)

        @declared_attr
        def parent(self):
            return relationship(Parent)
</code></pre></div>
<p dir="auto">Creating a factory that declares a class with the same attributes as are declared above in the Child class actually works, which is why this isn't very high priority, but it does make my code much less pythonic. Classes created from the factory below auto-populate as they should.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def create_child(name):
    class Child(Base):

        __tablename__ = name.lower()

        id = Column(Serial, ForeignKey(Parent.id), primary_key=True)

        parent = relationship(Parent)

    Child.__name__ = name
    return Child"><pre class="notranslate"><code class="notranslate">def create_child(name):
    class Child(Base):

        __tablename__ = name.lower()

        id = Column(Serial, ForeignKey(Parent.id), primary_key=True)

        parent = relationship(Parent)

    Child.__name__ = name
    return Child
</code></pre></div>
<h3 dir="auto">Describe the bug</h3>
<p dir="auto">I try to build the documentation into <code class="notranslate">epub</code> format to be able to read the docs on my ebook reader, as I couldn't find the pre-built <code class="notranslate">epub</code> anywhere on the <a href="https://www.sqlalchemy.org/" rel="nofollow">https://www.sqlalchemy.org/</a>.</p>
<p dir="auto">Unfortunately, this fails with the error.</p>
<p dir="auto">I tried <code class="notranslate">make html</code> to see if that's a general issue or only an issue with <code class="notranslate">epub</code>, and the <code class="notranslate">make html</code> works successfully.</p>
<h3 dir="auto">To Reproduce</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$ git clone git@github.com:sqlalchemy/sqlalchemy.git
$ cd sqlalchemy/doc/build/
$ git checkout rel_1_4_31
$ python3.10 -m venv venv
$ . venv/bin/activate
$ python --version
Python 3.10.0
$ pip install -r requirements.txt
$ pip install sphinx
$ pip freeze
alabaster==0.7.12
Babel==2.9.1
certifi==2021.10.8
changelog==0.5.8
charset-normalizer==2.0.12
docutils==0.17.1
idna==3.3
imagesize==1.3.0
Jinja2==3.0.3
libsass==0.21.0
Mako==1.1.6
MarkupSafe==2.1.0
packaging==21.3
Pygments==2.11.2
pyparsing==3.0.7
pytz==2021.3
requests==2.27.1
six==1.16.0
snowballstemmer==2.2.0
Sphinx==4.4.0
sphinx-paramlinks @ git+https://github.com/sqlalchemyorg/sphinx-paramlinks.git@acedb03149e3f87ff599174b033754c2f58f1c95
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
urllib3==1.26.8
zzzeeksphinx @ git+https://github.com/sqlalchemyorg/zzzeeksphinx.git@715c91f45c7b46e7c39528cae964f0d0891b421a
$ make epub"><pre class="notranslate">$ <span class="pl-s1">git</span> <span class="pl-s1">clone</span> <span class="pl-s1">git</span>@<span class="pl-s1">github</span>.<span class="pl-s1">com</span>:<span class="pl-s1">sqlalchemy</span><span class="pl-c1">/</span><span class="pl-s1">sqlalchemy</span>.<span class="pl-s1">git</span>
$ <span class="pl-s1">cd</span> <span class="pl-s1">sqlalchemy</span><span class="pl-c1">/</span><span class="pl-s1">doc</span><span class="pl-c1">/</span><span class="pl-s1">build</span><span class="pl-c1">/</span>
$ <span class="pl-s1">git</span> <span class="pl-s1">checkout</span> <span class="pl-s1">rel_1_4_31</span>
$ <span class="pl-s1">python3</span>.<span class="pl-c1">10</span> <span class="pl-c1">-</span><span class="pl-s1">m</span> <span class="pl-s1">venv</span> <span class="pl-s1">venv</span>
$ . <span class="pl-s1">venv</span><span class="pl-c1">/</span><span class="pl-s1">bin</span><span class="pl-c1">/</span><span class="pl-s1">activate</span>
$ <span class="pl-s1">python</span> <span class="pl-c1">-</span><span class="pl-c1">-</span><span class="pl-s1">version</span>
<span class="pl-v">Python</span> <span class="pl-c1">3.10</span><span class="pl-c1">.0</span>
$ <span class="pl-s1">pip</span> <span class="pl-s1">install</span> <span class="pl-c1">-</span><span class="pl-s1">r</span> <span class="pl-s1">requirements</span>.<span class="pl-s1">txt</span>
$ <span class="pl-s1">pip</span> <span class="pl-s1">install</span> <span class="pl-s1">sphinx</span>
$ <span class="pl-s1">pip</span> <span class="pl-s1">freeze</span>
<span class="pl-s1">alabaster</span><span class="pl-c1">==</span><span class="pl-c1">0.7</span>.<span class="pl-c1">12</span>
<span class="pl-v">Babel</span><span class="pl-c1">==</span><span class="pl-c1">2.9</span>.<span class="pl-c1">1</span>
<span class="pl-s1">certifi</span><span class="pl-c1">==</span><span class="pl-c1">2021.10</span>.<span class="pl-c1">8</span>
<span class="pl-s1">changelog</span><span class="pl-c1">==</span><span class="pl-c1">0.5</span>.<span class="pl-c1">8</span>
<span class="pl-s1">charset</span><span class="pl-c1">-</span><span class="pl-s1">normalizer</span><span class="pl-c1">==</span><span class="pl-c1">2.0</span>.<span class="pl-c1">12</span>
<span class="pl-s1">docutils</span><span class="pl-c1">==</span><span class="pl-c1">0.17</span>.<span class="pl-c1">1</span>
<span class="pl-s1">idna</span><span class="pl-c1">==</span><span class="pl-c1">3.3</span>
<span class="pl-s1">imagesize</span><span class="pl-c1">==</span><span class="pl-c1">1.3</span>.<span class="pl-c1">0</span>
<span class="pl-v">Jinja2</span><span class="pl-c1">==</span><span class="pl-c1">3.0</span>.<span class="pl-c1">3</span>
<span class="pl-s1">libsass</span><span class="pl-c1">==</span><span class="pl-c1">0.21</span>.<span class="pl-c1">0</span>
<span class="pl-v">Mako</span><span class="pl-c1">==</span><span class="pl-c1">1.1</span>.<span class="pl-c1">6</span>
<span class="pl-v">MarkupSafe</span><span class="pl-c1">==</span><span class="pl-c1">2.1</span>.<span class="pl-c1">0</span>
<span class="pl-s1">packaging</span><span class="pl-c1">==</span><span class="pl-c1">21.3</span>
<span class="pl-v">Pygments</span><span class="pl-c1">==</span><span class="pl-c1">2.11</span>.<span class="pl-c1">2</span>
<span class="pl-s1">pyparsing</span><span class="pl-c1">==</span><span class="pl-c1">3.0</span>.<span class="pl-c1">7</span>
<span class="pl-s1">pytz</span><span class="pl-c1">==</span><span class="pl-c1">2021.3</span>
<span class="pl-s1">requests</span><span class="pl-c1">==</span><span class="pl-c1">2.27</span>.<span class="pl-c1">1</span>
<span class="pl-s1">six</span><span class="pl-c1">==</span><span class="pl-c1">1.16</span>.<span class="pl-c1">0</span>
<span class="pl-s1">snowballstemmer</span><span class="pl-c1">==</span><span class="pl-c1">2.2</span>.<span class="pl-c1">0</span>
<span class="pl-v">Sphinx</span><span class="pl-c1">==</span><span class="pl-c1">4.4</span>.<span class="pl-c1">0</span>
<span class="pl-s1">sphinx</span><span class="pl-c1">-</span><span class="pl-s1">paramlinks</span> @ <span class="pl-s1">git</span><span class="pl-c1">+</span><span class="pl-s1">https</span>:<span class="pl-c1">//</span><span class="pl-s1">github</span>.<span class="pl-s1">com</span><span class="pl-c1">/</span><span class="pl-s1">sqlalchemyorg</span><span class="pl-c1">/</span><span class="pl-s1">sphinx</span><span class="pl-c1">-</span><span class="pl-s1">paramlinks</span>.<span class="pl-s1">git</span>@<span class="pl-s1">acedb03149e3f87ff599174b033754c2f58f1c95</span>
<span class="pl-s1">sphinxcontrib</span><span class="pl-c1">-</span><span class="pl-s1">applehelp</span><span class="pl-c1">==</span><span class="pl-c1">1.0</span>.<span class="pl-c1">2</span>
<span class="pl-s1">sphinxcontrib</span><span class="pl-c1">-</span><span class="pl-s1">devhelp</span><span class="pl-c1">==</span><span class="pl-c1">1.0</span>.<span class="pl-c1">2</span>
<span class="pl-s1">sphinxcontrib</span><span class="pl-c1">-</span><span class="pl-s1">htmlhelp</span><span class="pl-c1">==</span><span class="pl-c1">2.0</span>.<span class="pl-c1">0</span>
<span class="pl-s1">sphinxcontrib</span><span class="pl-c1">-</span><span class="pl-s1">jsmath</span><span class="pl-c1">==</span><span class="pl-c1">1.0</span>.<span class="pl-c1">1</span>
<span class="pl-s1">sphinxcontrib</span><span class="pl-c1">-</span><span class="pl-s1">qthelp</span><span class="pl-c1">==</span><span class="pl-c1">1.0</span>.<span class="pl-c1">3</span>
<span class="pl-s1">sphinxcontrib</span><span class="pl-c1">-</span><span class="pl-s1">serializinghtml</span><span class="pl-c1">==</span><span class="pl-c1">1.1</span>.<span class="pl-c1">5</span>
<span class="pl-s1">urllib3</span><span class="pl-c1">==</span><span class="pl-c1">1.26</span>.<span class="pl-c1">8</span>
<span class="pl-s1">zzzeeksphinx</span> @ <span class="pl-s1">git</span><span class="pl-c1">+</span><span class="pl-s1">https</span>:<span class="pl-c1">//</span><span class="pl-s1">github</span>.<span class="pl-s1">com</span><span class="pl-c1">/</span><span class="pl-s1">sqlalchemyorg</span><span class="pl-c1">/</span><span class="pl-s1">zzzeeksphinx</span>.<span class="pl-s1">git</span>@<span class="pl-c1">715</span><span class="pl-s1">c91f45c7b46e7c39528cae964f0d0891b421a</span>
$ <span class="pl-s1">make</span> <span class="pl-s1">epub</span></pre></div>
<h3 dir="auto">Error</h3>
<p dir="auto">After <code class="notranslate">$ make epub</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="sphinx-build -b epub -d output/doctrees  -T -j auto . output/epub
Running Sphinx v4.4.0
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [epub]: targets for 168 source files that are out of date
updating environment: [new config] 168 added, 0 changed, 0 removed
reading sources... [100%] tutorial/engine .. venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module
waiting for workers...
reading changelog note files (version 1.3.25)...[100%] 6392.rst
reading changelog note files (version 1.3.25)...[100%] 6392.rst
/Users/dstasczak/tmp/sqlalchemy/doc/build/tutorial/tutorial_nav_include.rst:9: ERROR: Undefined substitution referenced: &quot;prev&quot;.
/Users/dstasczak/tmp/sqlalchemy/doc/build/tutorial/tutorial_nav_include.rst:9: ERROR: Undefined substitution referenced: &quot;next&quot;.
/Users/dstasczak/tmp/sqlalchemy/doc/build/tutorial/tutorial_nav_include.rst:13: ERROR: Undefined substitution referenced: &quot;next&quot;.
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base.rst:3: ERROR: Error in &quot;currentmodule&quot; directive:
maximum 1 argument(s) allowed, 3 supplied.

.. currentmodule:: {{ module }}
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class.rst:3: ERROR: Error in &quot;currentmodule&quot; directive:
maximum 1 argument(s) allowed, 3 supplied.

.. currentmodule:: {{ module }}
WARNING: invalid signature for autoclass ('{{ objname }}')
WARNING: don't know which module to import for autodocumenting '{{ objname }}' (try placing a &quot;module&quot; or &quot;currentmodule&quot; directive in the document, or giving an explicit module name)
WARNING: invalid signature for automodule ('{{ fullname }}')
WARNING: don't know which module to import for autodocumenting '{{ fullname }}' (try placing a &quot;module&quot; or &quot;currentmodule&quot; directive in the document, or giving an explicit module name)
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst:53: ERROR: Unknown directive type &quot;autosummary&quot;.

.. autosummary::
   :toctree:
   :recursive:
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst:56: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst:58: WARNING: Definition list ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/ext/asyncio/scoping.py:docstring of sqlalchemy.ext.asyncio.session.connection:12: WARNING: Inline strong start-string without end-string.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/ext/asyncio/scoping.py:docstring of sqlalchemy.ext.asyncio.session.stream:4: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/ext/asyncio/session.py:docstring of sqlalchemy.ext.asyncio.session.AsyncSession.connection:8: WARNING: Inline strong start-string without end-string.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/orm/collections.py:docstring of sqlalchemy.orm.collections.collection:1: WARNING: duplicate object description of sqlalchemy.orm.collections.collection, other instance in orm/collections, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/doc/build/orm/contextual.rst:4: WARNING: Duplicate explicit target name: &quot;threading.local()&quot;.
/Users/dstasczak/tmp/sqlalchemy/doc/build/orm/extensions/mypy.rst:4: WARNING: Duplicate explicit target name: &quot;mypy&quot;.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in orm/internals, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/foundation, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/metadata, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/doc/build/core/reflection.rst:142: ERROR: Unknown interpreted text role &quot;method&quot;.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/metadata, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/selectable, use :noindex: for one of them
docstring of sqlalchemy.sql.expression.LABEL_STYLE_TABLENAME_PLUS_COL:6: WARNING: Inline literal start-string without end-string.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.CHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.CHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.NCHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.NCHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.NVARCHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.NVARCHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.TEXT:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.TEXT, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.VARCHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.VARCHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.BINARY:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.BINARY, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.BLOB:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.BLOB, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.BOOLEAN:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.BOOLEAN, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.DATE:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.DATE, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.VARBINARY:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.VARBINARY, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.REAL:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.REAL, other instance in core/type_basics, use :noindex: for one of them
changelog/changelog_07.rst:5: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/doc/build/changelog/changelog_11.rst:1: WARNING: Inline emphasis start-string without end-string.
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/Jinja2-3.0.3.dist-info/LICENSE.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/MarkupSafe-2.1.0.dist-info/LICENSE.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/alabaster-0.7.12.dist-info/DESCRIPTION.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/imagesize-1.3.0.dist-info/LICENSE.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
The name of the builder is: epubThe name of the builder is: epub
Traceback (most recent call last):
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/mako/lookup.py&quot;, line 249, in get_template
    return self._check(uri, self._collection[uri])
KeyError: 'page.mako'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/html/__init__.py&quot;, line 1055, in handle_page
    output = self.templates.render(templatename, ctx)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/zzzeeksphinx/mako.py&quot;, line 102, in render
    return self.lookup.get_template(template).render_unicode(**context)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/mako/lookup.py&quot;, line 262, in get_template
    raise exceptions.TopLevelLookupException(
mako.exceptions.TopLevelLookupException: Cant locate template for uri 'page.mako'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/cmd/build.py&quot;, line 284, in build_main
    app.build(args.force_all, filenames)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/application.py&quot;, line 337, in build
    self.builder.build_update()
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py&quot;, line 294, in build_update
    self.build(to_build,
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py&quot;, line 358, in build
    self.write(docnames, list(updated_docnames), method)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py&quot;, line 529, in write
    self._write_parallel(sorted(docnames),
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py&quot;, line 556, in _write_parallel
    self.write_doc(firstname, doctree)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/_epub_base.py&quot;, line 374, in write_doc
    super().write_doc(docname, doctree)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/html/__init__.py&quot;, line 632, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/_epub_base.py&quot;, line 467, in handle_page
    super().handle_page(pagename, addctx, templatename, outfilename, event_arg)
  File &quot;/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/html/__init__.py&quot;, line 1062, in handle_page
    raise ThemeError(__(&quot;An error happened in rendering the page %s.\nReason: %r&quot;) %
sphinx.errors.ThemeError: An error happened in rendering the page changelog/changelog_01.
Reason: TopLevelLookupException(&quot;Cant locate template for uri 'page.mako'&quot;)

Theme error:
An error happened in rendering the page changelog/changelog_01.
Reason: TopLevelLookupException(&quot;Cant locate template for uri 'page.mako'&quot;)
make: *** [epub] Error 2"><pre class="notranslate"><code class="notranslate">sphinx-build -b epub -d output/doctrees  -T -j auto . output/epub
Running Sphinx v4.4.0
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [epub]: targets for 168 source files that are out of date
updating environment: [new config] 168 added, 0 changed, 0 removed
reading sources... [100%] tutorial/engine .. venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module
waiting for workers...
reading changelog note files (version 1.3.25)...[100%] 6392.rst
reading changelog note files (version 1.3.25)...[100%] 6392.rst
/Users/dstasczak/tmp/sqlalchemy/doc/build/tutorial/tutorial_nav_include.rst:9: ERROR: Undefined substitution referenced: "prev".
/Users/dstasczak/tmp/sqlalchemy/doc/build/tutorial/tutorial_nav_include.rst:9: ERROR: Undefined substitution referenced: "next".
/Users/dstasczak/tmp/sqlalchemy/doc/build/tutorial/tutorial_nav_include.rst:13: ERROR: Undefined substitution referenced: "next".
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base.rst:3: ERROR: Error in "currentmodule" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. currentmodule:: {{ module }}
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class.rst:3: ERROR: Error in "currentmodule" directive:
maximum 1 argument(s) allowed, 3 supplied.

.. currentmodule:: {{ module }}
WARNING: invalid signature for autoclass ('{{ objname }}')
WARNING: don't know which module to import for autodocumenting '{{ objname }}' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
WARNING: invalid signature for automodule ('{{ fullname }}')
WARNING: don't know which module to import for autodocumenting '{{ fullname }}' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst:53: ERROR: Unknown directive type "autosummary".

.. autosummary::
   :toctree:
   :recursive:
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst:56: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst:58: WARNING: Definition list ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/ext/asyncio/scoping.py:docstring of sqlalchemy.ext.asyncio.session.connection:12: WARNING: Inline strong start-string without end-string.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/ext/asyncio/scoping.py:docstring of sqlalchemy.ext.asyncio.session.stream:4: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/ext/asyncio/session.py:docstring of sqlalchemy.ext.asyncio.session.AsyncSession.connection:8: WARNING: Inline strong start-string without end-string.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/orm/collections.py:docstring of sqlalchemy.orm.collections.collection:1: WARNING: duplicate object description of sqlalchemy.orm.collections.collection, other instance in orm/collections, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/doc/build/orm/contextual.rst:4: WARNING: Duplicate explicit target name: "threading.local()".
/Users/dstasczak/tmp/sqlalchemy/doc/build/orm/extensions/mypy.rst:4: WARNING: Duplicate explicit target name: "mypy".
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in orm/internals, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/foundation, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/metadata, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/doc/build/core/reflection.rst:142: ERROR: Unknown interpreted text role "method".
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/metadata, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py:docstring of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute:1: WARNING: duplicate object description of sqlalchemy.util.langhelpers.HasMemoized.memoized_attribute, other instance in core/selectable, use :noindex: for one of them
docstring of sqlalchemy.sql.expression.LABEL_STYLE_TABLENAME_PLUS_COL:6: WARNING: Inline literal start-string without end-string.
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.CHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.CHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.NCHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.NCHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.NVARCHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.NVARCHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.TEXT:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.TEXT, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.VARCHAR:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.VARCHAR, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.BINARY:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.BINARY, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.BLOB:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.BLOB, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.BOOLEAN:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.BOOLEAN, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.DATE:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.DATE, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.VARBINARY:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.VARBINARY, other instance in core/type_basics, use :noindex: for one of them
/Users/dstasczak/tmp/sqlalchemy/lib/sqlalchemy/sql/sqltypes.py:docstring of sqlalchemy.sql.sqltypes.REAL:1: WARNING: duplicate object description of sqlalchemy.sql.sqltypes.REAL, other instance in core/type_basics, use :noindex: for one of them
changelog/changelog_07.rst:5: WARNING: Explicit markup ends without a blank line; unexpected unindent.
/Users/dstasczak/tmp/sqlalchemy/doc/build/changelog/changelog_11.rst:1: WARNING: Inline emphasis start-string without end-string.
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/Jinja2-3.0.3.dist-info/LICENSE.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/MarkupSafe-2.1.0.dist-info/LICENSE.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/alabaster-0.7.12.dist-info/DESCRIPTION.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/imagesize-1.3.0.dist-info/LICENSE.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/base.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/class.rst: WARNING: document isn't included in any toctree
/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/ext/autosummary/templates/autosummary/module.rst: WARNING: document isn't included in any toctree
done
preparing documents... done
The name of the builder is: epubThe name of the builder is: epub
Traceback (most recent call last):
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/mako/lookup.py", line 249, in get_template
    return self._check(uri, self._collection[uri])
KeyError: 'page.mako'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 1055, in handle_page
    output = self.templates.render(templatename, ctx)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/zzzeeksphinx/mako.py", line 102, in render
    return self.lookup.get_template(template).render_unicode(**context)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/mako/lookup.py", line 262, in get_template
    raise exceptions.TopLevelLookupException(
mako.exceptions.TopLevelLookupException: Cant locate template for uri 'page.mako'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/cmd/build.py", line 284, in build_main
    app.build(args.force_all, filenames)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/application.py", line 337, in build
    self.builder.build_update()
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    self.build(to_build,
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 358, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 529, in write
    self._write_parallel(sorted(docnames),
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 556, in _write_parallel
    self.write_doc(firstname, doctree)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/_epub_base.py", line 374, in write_doc
    super().write_doc(docname, doctree)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 632, in write_doc
    self.handle_page(docname, ctx, event_arg=doctree)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/_epub_base.py", line 467, in handle_page
    super().handle_page(pagename, addctx, templatename, outfilename, event_arg)
  File "/Users/dstasczak/tmp/sqlalchemy/doc/build/venv/lib/python3.10/site-packages/sphinx/builders/html/__init__.py", line 1062, in handle_page
    raise ThemeError(__("An error happened in rendering the page %s.\nReason: %r") %
sphinx.errors.ThemeError: An error happened in rendering the page changelog/changelog_01.
Reason: TopLevelLookupException("Cant locate template for uri 'page.mako'")

Theme error:
An error happened in rendering the page changelog/changelog_01.
Reason: TopLevelLookupException("Cant locate template for uri 'page.mako'")
make: *** [epub] Error 2
</code></pre></div>
<h3 dir="auto">Versions</h3>
<ul dir="auto">
<li>OS: macOS Mojave Version 10.14.6 (18G9323)</li>
<li>Python: 3.10.0</li>
<li>SQLAlchemy: <code class="notranslate">rel_1_4_31</code></li>
<li>Database: None</li>
<li>DBAPI (eg: psycopg, cx_oracle, mysqlclient): None</li>
</ul>
<h3 dir="auto">Additional context</h3>
<p dir="auto"><em>No response</em></p>