Skip to content

Test failures with sphinx 4.0.1 #176

@loqs

Description

@loqs

Describe the bug
Updating from sphinx 3.5.4 to 4.0.1 produces two test failures.
Using sphinx-autodoc-typehints 1.12.0 python 3.9.5.

Expected behavior
All tests should pass.

Additional context

============================= test session starts ==============================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /build/python-sphinx-autodoc-typehints/src/sphinx-autodoc-typehints, configfile: pyproject.toml, testpaths: tests
collecting ... collected 89 items

tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[str] PASSED [  1%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[None] PASSED [  2%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Any] PASSED [  3%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[AnyStr] PASSED [  4%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Dict] PASSED [  5%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Dict_parametrized] PASSED [  6%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Dict_typevar] PASSED [  7%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Tuple] PASSED [  8%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Tuple_parametrized] PASSED [ 10%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Union] PASSED [ 11%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Callable] PASSED [ 12%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Callable_returntype] PASSED [ 13%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Callable_all_types] PASSED [ 14%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Pattern] PASSED [ 15%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Pattern_parametrized] PASSED [ 16%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Match] PASSED [ 17%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Match_parametrized] PASSED [ 19%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[IO] PASSED [ 20%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[W] PASSED  [ 21%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Metaclass] PASSED [ 22%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Slotted] PASSED [ 23%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[A] PASSED  [ 24%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[B] PASSED  [ 25%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[C] PASSED  [ 26%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[D] PASSED  [ 28%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[E] PASSED  [ 29%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[E_parametrized] PASSED [ 30%]
tests/test_sphinx_autodoc_typehints.py::test_parse_annotation[Inner] PASSED [ 31%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[str-:py:class:`str`] PASSED [ 32%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[int-:py:class:`int`] PASSED [ 33%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[NoneType-:py:obj:`None`] PASSED [ 34%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[type-:py:class:`type`] PASSED [ 35%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation4-:py:class:`~typing.Type`] PASSED [ 37%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation5-:py:class:`~typing.Type`\\[:py:class:`~test_sphinx_autodoc_typehints.A`]] PASSED [ 38%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation6-:py:data:`~typing.Any`] PASSED [ 39%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[AnyStr-:py:data:`~typing.AnyStr`] PASSED [ 40%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation8-:py:class:`~typing.Generic`\\[\\~T]] PASSED [ 41%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation9-:py:class:`~typing.Mapping`] PASSED [ 42%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation10-:py:class:`~typing.Mapping`\\[\\~T, :py:class:`int`]] PASSED [ 43%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation11-:py:class:`~typing.Mapping`\\[:py:class:`str`, \\-V]] PASSED [ 44%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation12-:py:class:`~typing.Mapping`\\[\\~T, \\+U]] PASSED [ 46%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation13-:py:class:`~typing.Mapping`\\[:py:class:`str`, :py:class:`bool`]] PASSED [ 47%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation14-:py:class:`~typing.Dict`] PASSED [ 48%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation15-:py:class:`~typing.Dict`\\[\\~T, :py:class:`int`]] PASSED [ 49%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation16-:py:class:`~typing.Dict`\\[:py:class:`str`, \\-V]] PASSED [ 50%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation17-:py:class:`~typing.Dict`\\[\\~T, \\+U]] PASSED [ 51%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation18-:py:class:`~typing.Dict`\\[:py:class:`str`, :py:class:`bool`]] PASSED [ 52%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation19-:py:data:`~typing.Tuple`] PASSED [ 53%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation20-:py:data:`~typing.Tuple`\\[:py:class:`str`, :py:class:`bool`]] PASSED [ 55%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation21-:py:data:`~typing.Tuple`\\[:py:class:`int`, :py:class:`int`, :py:class:`int`]] PASSED [ 56%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation22-:py:data:`~typing.Tuple`\\[:py:class:`str`, ...]] PASSED [ 57%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation23-:py:data:`~typing.Union`] PASSED [ 58%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation24-:py:data:`~typing.Union`\\[:py:class:`str`, :py:class:`bool`]] PASSED [ 59%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation25-:py:data:`~typing.Union`\\[:py:class:`str`, :py:class:`bool`, :py:obj:`None`]] PASSED [ 60%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation26-:py:data:`~typing.Union`\\[:py:class:`str`, :py:data:`~typing.Any`]] PASSED [ 61%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation27-:py:data:`~typing.Optional`\\[:py:class:`str`]] PASSED [ 62%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation28-:py:data:`~typing.Union`\\[:py:class:`str`, :py:class:`bool`, :py:obj:`None`]] PASSED [ 64%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation29-:py:data:`~typing.Callable`] PASSED [ 65%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation30-:py:data:`~typing.Callable`\\[..., :py:class:`int`]] PASSED [ 66%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation31-:py:data:`~typing.Callable`\\[\\[:py:class:`int`], :py:class:`int`]] PASSED [ 67%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation32-:py:data:`~typing.Callable`\\[\\[:py:class:`int`, :py:class:`str`], :py:class:`bool`]] PASSED [ 68%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation33-:py:data:`~typing.Callable`\\[\\[:py:class:`int`, :py:class:`str`], :py:obj:`None`]] PASSED [ 69%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation34-:py:data:`~typing.Callable`\\[\\[\\~T], \\~T]] PASSED [ 70%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation35-:py:class:`~typing.Pattern`] PASSED [ 71%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation36-:py:class:`~typing.Pattern`\\[:py:class:`str`]] PASSED [ 73%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[IO-:py:class:`~typing.IO`] PASSED [ 74%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation38-:py:class:`~typing.IO`\\[:py:class:`str`]] PASSED [ 75%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[Metaclass-:py:class:`~test_sphinx_autodoc_typehints.Metaclass`] PASSED [ 76%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[A-:py:class:`~test_sphinx_autodoc_typehints.A`] PASSED [ 77%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[B-:py:class:`~test_sphinx_autodoc_typehints.B`] PASSED [ 78%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation42-:py:class:`~test_sphinx_autodoc_typehints.B`\\[:py:class:`int`]] PASSED [ 79%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[C-:py:class:`~test_sphinx_autodoc_typehints.C`] PASSED [ 80%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[D-:py:class:`~test_sphinx_autodoc_typehints.D`] PASSED [ 82%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[E-:py:class:`~test_sphinx_autodoc_typehints.E`] PASSED [ 83%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[annotation46-:py:class:`~test_sphinx_autodoc_typehints.E`\\[:py:class:`int`]] PASSED [ 84%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation[W-:py:func:`~typing.NewType`\\(:py:data:`~W`, :py:class:`str`)] PASSED [ 85%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[ClassVar-int-:py:data:`~typing.ClassVar`\\[:py:class:`int`]-typing] PASSED [ 86%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[ClassVar-int-:py:data:`~typing.ClassVar`\\[:py:class:`int`]-typing_extensions] PASSED [ 87%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[NoReturn-None-:py:data:`~typing.NoReturn`-typing] PASSED [ 88%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[NoReturn-None-:py:data:`~typing.NoReturn`-typing_extensions] PASSED [ 89%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[Literal-params2-:py:data:`~typing.Literal`\\['a', 1]-typing] PASSED [ 91%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[Literal-params2-:py:data:`~typing.Literal`\\['a', 1]-typing_extensions] PASSED [ 92%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[Type-None-:py:class:`~typing.Type`-typing] PASSED [ 93%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[Type-None-:py:class:`~typing.Type`-typing_extensions] PASSED [ 94%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[Type-params4-:py:class:`~typing.Type`\\[:py:class:`~test_sphinx_autodoc_typehints.A`]-typing] PASSED [ 95%]
tests/test_sphinx_autodoc_typehints.py::test_format_annotation_both_libs[Type-params4-:py:class:`~typing.Type`\\[:py:class:`~test_sphinx_autodoc_typehints.A`]-typing_extensions] PASSED [ 96%]
tests/test_sphinx_autodoc_typehints.py::test_process_docstring_slot_wrapper PASSED [ 97%]
tests/test_sphinx_autodoc_typehints.py::test_sphinx_output[True] FAILED  [ 98%]
tests/test_sphinx_autodoc_typehints.py::test_sphinx_output[False] FAILED [100%]

=================================== FAILURES ===================================
___________________________ test_sphinx_output[True] ___________________________
tests/test_sphinx_autodoc_typehints.py:528: in test_sphinx_output
    assert text_contents == expected_contents
E   AssertionError: assert 'Dummy Module...-- function\n' == 'Dummy Module...-- function\n'
E       Dummy Module
E       ************
E       
E       class dummy_module.Class(x, y, z=None)
E       
E          Initializer docstring.
E       ...
E     
E     ...Full output truncated (272 lines hidden), use '-vv' to show
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: text
# srcdir: /tmp/pytest-of-builduser/pytest-0/dummy
# outdir: /tmp/pytest-of-builduser/pytest-0/dummy/_build/text
# status: 
Running Sphinx v4.0.1
building [mo]: targets for 0 po files that are out of date
building [text]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                 
build succeeded, 2 warnings.

The text files are in ../../../../tmp/pytest-of-builduser/pytest-0/dummy/_build/text.

# warning: 
WARNING: Cannot treat a function defined as a local function: "dummy_module.Class.locally_defined_callable_field"  (use @functools.wraps)
WARNING: Cannot resolve forward reference in type annotations of "dummy_module.function_with_unresolvable_annotation": name 'a' is not defined

__________________________ test_sphinx_output[False] ___________________________
tests/test_sphinx_autodoc_typehints.py:528: in test_sphinx_output
    assert text_contents == expected_contents
E   AssertionError: assert 'Dummy Module...-- function\n' == 'Dummy Module...-- function\n'
E       Dummy Module
E       ************
E       
E       class dummy_module.Class(x, y, z=None)
E       
E          Initializer docstring.
E       ...
E     
E     ...Full output truncated (263 lines hidden), use '-vv' to show
--------------------------- Captured stdout teardown ---------------------------
# testroot: root
# builder: text
# srcdir: /tmp/pytest-of-builduser/pytest-0/dummy
# outdir: /tmp/pytest-of-builduser/pytest-0/dummy/_build/text
# status: 
Running Sphinx v4.0.1
building [mo]: targets for 0 po files that are out of date
building [text]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                 
build succeeded, 2 warnings.

The text files are in ../../../../tmp/pytest-of-builduser/pytest-0/dummy/_build/text.

# warning: 
WARNING: Cannot treat a function defined as a local function: "dummy_module.Class.locally_defined_callable_field"  (use @functools.wraps)
WARNING: Cannot resolve forward reference in type annotations of "dummy_module.function_with_unresolvable_annotation": name 'a' is not defined

=============================== warnings summary ===============================
../../../../usr/lib/python3.9/site-packages/packaging/version.py:127: 344 warnings
  /usr/lib/python3.9/site-packages/packaging/version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================== 2 failed, 87 passed, 344 warnings in 0.95s ==================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions