diff --git a/doc/usage/extensions/napoleon.rst b/doc/usage/extensions/napoleon.rst index e1f90b562..59ecad890 100644 --- a/doc/usage/extensions/napoleon.rst +++ b/doc/usage/extensions/napoleon.rst @@ -136,7 +136,7 @@ separate sections, whereas NumPy uses underlines. Google style: -.. code-block:: python3 +.. code-block:: python def func(arg1, arg2): """Summary line. @@ -155,7 +155,7 @@ Google style: NumPy style: -.. code-block:: python3 +.. code-block:: python def func(arg1, arg2): """Summary line. diff --git a/doc/usage/restructuredtext/roles.rst b/doc/usage/restructuredtext/roles.rst index 9d790b30e..e2755dd4e 100644 --- a/doc/usage/restructuredtext/roles.rst +++ b/doc/usage/restructuredtext/roles.rst @@ -349,7 +349,7 @@ different style: The name of a file or directory. Within the contents, you can use curly braces to indicate a "variable" part, for example:: - ... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... + ... is installed in :file:`/usr/lib/python3.{x}/site-packages` ... In the built documentation, the ``x`` will be displayed differently to indicate that it is to be replaced by the Python minor version. diff --git a/sphinx/ext/autodoc/importer.py b/sphinx/ext/autodoc/importer.py index d392ae75d..977cfbba4 100644 --- a/sphinx/ext/autodoc/importer.py +++ b/sphinx/ext/autodoc/importer.py @@ -3,7 +3,7 @@ import importlib import traceback import warnings -from typing import Any, Callable, Dict, List, NamedTuple, Optional +from typing import TYPE_CHECKING, Any, Callable, Dict, List, NamedTuple, Optional from sphinx.ext.autodoc.mock import ismock, undecorate from sphinx.pycode import ModuleAnalyzer, PycodeError @@ -11,10 +11,7 @@ from sphinx.util import logging from sphinx.util.inspect import (getannotations, getmro, getslots, isclass, isenumclass, safe_getattr) -if False: - # For type annotation - from typing import Type # NOQA - +if TYPE_CHECKING: from sphinx.ext.autodoc import ObjectMember logger = logging.getLogger(__name__) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index b25a75fb5..2321a95dc 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -28,10 +28,6 @@ else: MethodDescriptorType = type(str.join) WrapperDescriptorType = type(dict.__dict__['fromkeys']) -if False: - # For type annotation - from typing import Type # NOQA - logger = logging.getLogger(__name__) memory_address_re = re.compile(r' at 0x[0-9a-f]{8,16}(?=>)', re.IGNORECASE) diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index 8e48b184b..c070eb00c 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -30,11 +30,6 @@ try: except ImportError: UnionType = None -if False: - # For type annotation - from typing import Type # NOQA # for python3.5.1 - - # builtin classes that have incorrect __module__ INVALID_BUILTIN_CLASSES = { Struct: 'struct.Struct', # Before Python 3.9 diff --git a/tests/test_pycode_parser.py b/tests/test_pycode_parser.py index 5d2496ba5..fde648d35 100644 --- a/tests/test_pycode_parser.py +++ b/tests/test_pycode_parser.py @@ -111,6 +111,9 @@ def test_complex_assignment(): 'f = g = None #: multiple assignment at once\n' '(theta, phi) = (0, 0.5) #: unpack assignment via tuple\n' '[x, y] = (5, 6) #: unpack assignment via list\n' + 'h, *i, j = (1, 2, 3, 4) #: unpack assignment2\n' + 'k, *self.attr = (5, 6, 7) #: unpack assignment3\n' + 'l, *m[0] = (8, 9, 0) #: unpack assignment4\n' ) parser = Parser(source) parser.parse() @@ -124,22 +127,11 @@ def test_complex_assignment(): ('', 'phi'): 'unpack assignment via tuple', ('', 'x'): 'unpack assignment via list', ('', 'y'): 'unpack assignment via list', - } - assert parser.definitions == {} - - -def test_complex_assignment_py3(): - source = ('a, *b, c = (1, 2, 3, 4) #: unpack assignment\n' - 'd, *self.attr = (5, 6, 7) #: unpack assignment2\n' - 'e, *f[0] = (8, 9, 0) #: unpack assignment3\n' - ) - parser = Parser(source) - parser.parse() - assert parser.comments == {('', 'a'): 'unpack assignment', - ('', 'b'): 'unpack assignment', - ('', 'c'): 'unpack assignment', - ('', 'd'): 'unpack assignment2', - ('', 'e'): 'unpack assignment3', + ('', 'h'): 'unpack assignment2', + ('', 'i'): 'unpack assignment2', + ('', 'j'): 'unpack assignment2', + ('', 'k'): 'unpack assignment3', + ('', 'l'): 'unpack assignment4', } assert parser.definitions == {}