Skip to content

Sphinx doesn't support python 3.10 #9562

Closed

Description

@Itotutona

Problem

Recently, I updated Python 3.9.6 to Python 3.10 RC. No problems. When I want to compile my Sphinx documentation (make html), I see:

$ make build
sphinx-build -b html -d _build/doctrees . _build/html
Traceback (most recent call last):
File "/home/titouan/.local/bin/sphinx-build", line 5, in
from sphinx.cmd.build import main
File "/home/titouan/.local/lib/python3.10/site-packages/sphinx/cmd/build.py", line 25, in
from sphinx.application import Sphinx
File "/home/titouan/.local/lib/python3.10/site-packages/sphinx/application.py", line 32, in
from sphinx.config import Config
File "/home/titouan/.local/lib/python3.10/site-packages/sphinx/config.py", line 21, in
from sphinx.util import logging
File "/home/titouan/.local/lib/python3.10/site-packages/sphinx/util/init.py", line 41, in
from sphinx.util.typing import PathMatcher
File "/home/titouan/.local/lib/python3.10/site-packages/sphinx/util/typing.py", line 37, in
from types import Union as types_Union
ImportError: cannot import name 'Union' from 'types' (/usr/lib64/python3.10/types.py)
make: *** [Makefile:53 : html] Erreur 1

Union is no longer in types

I suggest you update the sphinx code to be usable with oython 3.10 as it will be released very soon
If you want some help, I can contribute to sphinx.

Solution

I suggest you update the sphinx code to be usable with python 3.10 as it will be released very soon ( 4 october )
If you want some help, I can contribute to sphinx.

Additional context

Activity

  1. astrojuanlu commented on Aug 19, 2021

    @astrojuanlu
    Contributor

    Hi @Itotutona , you forgot to say what version of Sphinx are you using. I see that this error should be fixed at least on master:

    try:
    from types import UnionType # type: ignore # python 3.10 or above
    except ImportError:
    UnionType = None

  2. Itotutona commented on Aug 19, 2021

    @Itotutona
    Author

    @astrojuanlu I use 4.1.2

  3. jaraco commented on Aug 29, 2021

    @jaraco

    I just attempted to build docs using Sphinx and Python 3.10 and the issue still exists. I can work around it by building docs on Python 3.9. If the issue is fixed on master, maybe consider cutting a release with the fix so that others like me don't have to encounter the issue.

  4. psss commented on Sep 1, 2021

    @psss

    Confirm the problem is still present when testing with the latest Fedora (35 and Rawhide).

  5. astrojuanlu commented on Sep 1, 2021

    @astrojuanlu
    Contributor

    From my understanding, the problem is present in Sphinx 4.1.2:

    if sys.version_info > (3, 10):
    from types import Union as types_Union
    else:
    types_Union = None

    but it was fixed on the master and 4.1.x branches:

    try:
    from types import UnionType # type: ignore # python 3.10 or above
    except ImportError:
    UnionType = None

    Can folks try to reproduce the problem with the development version?

  6. astrojuanlu commented on Sep 1, 2021

    @astrojuanlu
    Contributor

    In principle, this issue is a duplicate of #9512, which was fixed in #9513.

  7. jaraco commented on Sep 4, 2021

    @jaraco

    I just attempted to build docs using Sphinx and Python 3.10 and the issue still exists. I can work around it by building docs on Python 3.9. If the issue is fixed on master, maybe consider cutting a release with the fix so that others like me don't have to encounter the issue.

    This issue cause a failed release of Setuptools requiring a workaround to be committed to the repo and adding debt to remove that workaround later. Please consider cutting a release so that there is a working published version of Sphinx for Python 3.10.

  8. reopened this on Sep 5, 2021
  9. tk0miya commented on Sep 5, 2021

    @tk0miya
    Member

    4.2.0 will be released the next weekend. Please wait a moment more.

  10. locked as resolved and limited conversation to collaborators on Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:enhancementenhance or introduce a new feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions