Skip to content

Commit

Permalink
Remove redundant code for Python < 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed May 1, 2022
1 parent 2f29f0a commit 184fe83
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 34 deletions.
1 change: 0 additions & 1 deletion tests/test_ext_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,6 @@ def test_type_union_operator(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_hide_value(app):
options = {'members': None}
Expand Down
5 changes: 0 additions & 5 deletions tests/test_ext_autodoc_autoattribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def test_autoattribute_novalue(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autoattribute_typed_variable(app):
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Class.attr2')
Expand All @@ -52,7 +51,6 @@ def test_autoattribute_typed_variable(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autoattribute_typed_variable_in_alias(app):
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Alias.attr2')
Expand All @@ -65,7 +63,6 @@ def test_autoattribute_typed_variable_in_alias(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autoattribute_instance_variable(app):
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Class.attr4')
Expand All @@ -80,7 +77,6 @@ def test_autoattribute_instance_variable(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autoattribute_instance_variable_in_alias(app):
actual = do_autodoc(app, 'attribute', 'target.typed_vars.Alias.attr4')
Expand Down Expand Up @@ -198,7 +194,6 @@ def test_autoattribute_TypeVar(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autoattribute_hide_value(app):
actual = do_autodoc(app, 'attribute', 'target.hide_value.Foo.SENTINEL1')
Expand Down
2 changes: 0 additions & 2 deletions tests/test_ext_autodoc_autoclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def test_inherited_instance_variable(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is available since python3.6.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_uninitialized_attributes(app):
options = {"members": None,
Expand Down Expand Up @@ -130,7 +129,6 @@ def test_uninitialized_attributes(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='py36+ is available since python3.6.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_undocumented_uninitialized_attributes(app):
options = {"members": None,
Expand Down
3 changes: 0 additions & 3 deletions tests/test_ext_autodoc_autodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def test_autodata_novalue(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodata_typed_variable(app):
actual = do_autodoc(app, 'data', 'target.typed_vars.attr2')
Expand All @@ -54,7 +53,6 @@ def test_autodata_typed_variable(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodata_type_comment(app):
actual = do_autodoc(app, 'data', 'target.typed_vars.attr3')
Expand Down Expand Up @@ -126,7 +124,6 @@ def test_autodata_TypeVar(app):
]


@pytest.mark.skipif(sys.version_info < (3, 6), reason='python 3.6+ is required.')
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodata_hide_value(app):
actual = do_autodoc(app, 'data', 'target.hide_value.SENTINEL1')
Expand Down
42 changes: 19 additions & 23 deletions tests/test_ext_napoleon_docstring.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Tests for :mod:`sphinx.ext.napoleon.docstring` module."""

import re
import sys
from collections import namedtuple
from contextlib import contextmanager
from inspect import cleandoc
Expand All @@ -15,9 +14,8 @@
_convert_numpy_type_spec, _recombine_set_tokens,
_token_type, _tokenize_type_spec)

if sys.version_info >= (3, 6):
from .ext_napoleon_pep526_data_google import PEP526GoogleClass
from .ext_napoleon_pep526_data_numpy import PEP526NumpyClass
from .ext_napoleon_pep526_data_google import PEP526GoogleClass
from .ext_napoleon_pep526_data_numpy import PEP526NumpyClass


class NamedtupleSubclass(namedtuple('NamedtupleSubclass', ('attr1', 'attr2'))):
Expand Down Expand Up @@ -1162,14 +1160,13 @@ def test_keywords_with_types(self):
self.assertEqual(expected, actual)

def test_pep526_annotations(self):
if sys.version_info >= (3, 6):
# Test class attributes annotations
config = Config(
napoleon_attr_annotations=True
)
actual = str(GoogleDocstring(cleandoc(PEP526GoogleClass.__doc__), config, app=None, what="class",
obj=PEP526GoogleClass))
expected = """\
# Test class attributes annotations
config = Config(
napoleon_attr_annotations=True
)
actual = str(GoogleDocstring(cleandoc(PEP526GoogleClass.__doc__), config, app=None, what="class",
obj=PEP526GoogleClass))
expected = """\
Sample class with PEP 526 annotations and google docstring
.. attribute:: attr1
Expand All @@ -1184,7 +1181,7 @@ def test_pep526_annotations(self):
:type: str
"""
self.assertEqual(expected, actual)
self.assertEqual(expected, actual)

def test_preprocess_types(self):
docstring = """\
Expand Down Expand Up @@ -2573,14 +2570,13 @@ def test_escape_args_and_kwargs(self, name, expected):
assert actual == expected

def test_pep526_annotations(self):
if sys.version_info >= (3, 6):
# test class attributes annotations
config = Config(
napoleon_attr_annotations=True
)
actual = str(NumpyDocstring(cleandoc(PEP526NumpyClass.__doc__), config, app=None, what="class",
obj=PEP526NumpyClass))
expected = """\
# test class attributes annotations
config = Config(
napoleon_attr_annotations=True
)
actual = str(NumpyDocstring(cleandoc(PEP526NumpyClass.__doc__), config, app=None, what="class",
obj=PEP526NumpyClass))
expected = """\
Sample class with PEP 526 annotations and numpy docstring
.. attribute:: attr1
Expand All @@ -2595,5 +2591,5 @@ def test_pep526_annotations(self):
:type: str
"""
print(actual)
assert expected == actual
print(actual)
assert expected == actual

0 comments on commit 184fe83

Please sign in to comment.