Skip to content

Commit

Permalink
Revert "skip type annotations for 3.7, which fails for unknown reasons"
Browse files Browse the repository at this point in the history
This reverts commit 59c3f83.
  • Loading branch information
basnijholt authored and gaborbernat committed Dec 31, 2021
1 parent f5ab7ae commit 0281755
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,8 @@ def _is_dataclass(name: str, what: str, qualname: str) -> bool:


def _future_annotations_imported(obj):
if sys.version_info < (3, 8):
# Only Python ≥ 3.7 supports PEP563, however
# Python 3.7 doesn't give the expected results.
# TODO: make it work for Python 3.7.
if sys.version_info < (3, 7):
# Only Python ≥ 3.7 supports PEP563.
return False

_annotations = getattr(inspect.getmodule(obj), "annotations", None)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_sphinx_autodoc_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ def test_sphinx_output(app, status, warning, always_document_param_types):

app.config.always_document_param_types = always_document_param_types
app.config.autodoc_mock_imports = ['mailbox']
if sys.version_info < (3, 8):
# TODO: fix for Python 3.7
if sys.version_info < (3, 7):
app.config.autodoc_mock_imports.append('dummy_module_future_annotations')
app.build()

Expand Down Expand Up @@ -560,8 +559,7 @@ class dummy_module.DataClass(x)
assert text_contents == maybe_fix_py310(expected_contents)


# TODO: fix for Python 3.7, which *should* work but fails for unknown reasons
@pytest.mark.skipif(sys.version_info < (3, 8),
@pytest.mark.skipif(sys.version_info < (3, 7),
reason="Future annotations are not implemented in Python < 3.7")
@pytest.mark.sphinx('text', testroot='dummy')
@patch('sphinx.writers.text.MAXWIDTH', 2000)
Expand Down

0 comments on commit 0281755

Please sign in to comment.