Skip to content

Python 3.11: "WARNING: Literal block expected; none found" #10410

@hugovk

Description

@hugovk

Describe the bug

When building docs with enums like this:

.. autoclass:: Transpose
    :members:
    :undoc-members:

Referring to code like this:

class Transpose(IntEnum):
    FLIP_LEFT_RIGHT = 0
    FLIP_TOP_BOTTOM = 1
    ROTATE_90 = 2
    ROTATE_180 = 3
    ROTATE_270 = 4
    TRANSPOSE = 5
    TRANSVERSE = 6

I get no warnings with Python 3.10. But with Python 3.11 I get a warning:

/Users/huvankem/github/Pillow/src/PIL/Image.py:docstring of PIL.Image.Transpose:7: WARNING: Literal block expected; none found.

How to Reproduce

$ git clone https://github.com/python-pillow/Pillow/
$ cd Pillow
$ pip install -e ".[docs]"
$ cd docs
$ python3.11 -m sphinx.cmd.build -b html -W --keep-going . _build/html

Expected behavior

No warnings, like with Python 3.10:

$ python3.10 -m sphinx.cmd.build -b html -W --keep-going . _build/html

Your project

https://github.com/python-pillow/Pillow

Screenshots

image

OS

macOS 12.3.1 Monterey and Linux 20.04

Python version

Python 3.11.0a7+

Sphinx version

4.5.0

Sphinx extensions

sphinx_copybutton, sphinx_issues, sphinx_removed_in, sphinx.ext.autodoc, sphinx.ext.intersphinx, sphinx.ext.viewcode, sphinxext.opengraph

Extra tools

No response

Additional context

If I add a docstring to the enum the warning goes away:

class Transpose(IntEnum):
    """My docstring"""
    FLIP_LEFT_RIGHT = 0
    FLIP_TOP_BOTTOM = 1
    ROTATE_90 = 2
    ROTATE_180 = 3
    ROTATE_270 = 4
    TRANSPOSE = 5
    TRANSVERSE = 6

Which is probably a good idea anyway, but I wanted to check if this is an intentional change with Python 3.11, something that needs changing in Sphinx to handle 3.11, or (like #10030) a bug in 3.11.

(3.11 enters beta next week, and is set for full release in October.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions