Skip to content

4.1.2 test suite regressions with Python 3.10.0b4: TypeError: isinstance() arg 2 must be a type, a tuple of types or a union #9505

@mgorny

Description

@mgorny

Describe the bug

Sphinx 4.1.2's test suite has 367 test failures and 13 errors with Python 3.10.0b4. They all seem to have a common cause in:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

obj = <class 'autodoc_target.Class'>

    def isNewType(obj: Any) -> bool:
        """Check the if object is a kind of NewType."""
        if sys.version_info >= (3, 10):
>           return isinstance(obj, typing.NewType)
E           TypeError: isinstance() arg 2 must be a type, a tuple of types or a union

obj        = <class 'autodoc_target.Class'>

sphinx/util/inspect.py:215: TypeError

How to Reproduce

$ git clone https://github.com/sphinx-doc/sphinx
$ cd sphinx
$ tox -e py310

Expected behavior

No response

Your project

n/a

Screenshots

No response

OS

Gentoo Linux

Python version

3.10.0b4

Sphinx version

4.1.2 (+ git master)

Sphinx extensions

No response

Extra tools

No response

Additional context

Full superverbose build log (17M): dev-python:sphinx-4.1.2:20210727-064745.log

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions