A Python class with type annotation produces a warning: WARNING: duplicate object description during the sphinx-build if the sphinx.ext.napoleon extension is used. This used to not produce any warnings on version 1.8.5 of sphinx, but produces the warnings in version 3.4.3.
To Reproduce
Steps to reproduce the behavior:
#!/usr/bin/env bash
set -e
set -x
mkdir repro && cd repro
mkdir -p docs/source
cat << EOF > generate_warning.py
class Test:
"""
Attributes:
attr: a doc
"""
attr: bool
EOF
cat << EOF > docs/source/conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))
extensions = [
'sphinx.ext.napoleon',
]
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
EOF
cat << EOF > docs/source/index.rst
.. toctree::
apidoc/modules
EOF
# I use conda to create environemnts, but if you don't create a virtual env with
# sphinx 3.4.3 instead of the following block
cat << EOF > environment.yml
name: sphinx-duplicate-warning
channels:
- conda-forge
- nodefaults
dependencies:
- sphinx==3.4.3
EOF
conda env create
Then activate the environment and run sphinx build:
cd repro
conda activate sphinx-duplicate-warning
sphinx-apidoc --force --separate -o docs/source/apidoc . && sphinx-build -M html "docs/source" "build"
A Python class with type annotation produces a warning:
WARNING: duplicate object description
during thesphinx-build
if thesphinx.ext.napoleon
extension is used. This used to not produce any warnings on version 1.8.5 of sphinx, but produces the warnings in version 3.4.3.To Reproduce Steps to reproduce the behavior:
Then activate the environment and run sphinx build:
Expected behavior No warning
Your project repro.zip
Environment info