Remove traces of Python 2 and 3.5 (#10560)

This commit is contained in:
Adam Turner 2022-06-16 21:37:46 +01:00 committed by GitHub
parent 6d23d7d153
commit 70f950cae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 33 deletions

View File

@ -136,7 +136,7 @@ separate sections, whereas NumPy uses underlines.
Google style: Google style:
.. code-block:: python3 .. code-block:: python
def func(arg1, arg2): def func(arg1, arg2):
"""Summary line. """Summary line.
@ -155,7 +155,7 @@ Google style:
NumPy style: NumPy style:
.. code-block:: python3 .. code-block:: python
def func(arg1, arg2): def func(arg1, arg2):
"""Summary line. """Summary line.

View File

@ -349,7 +349,7 @@ different style:
The name of a file or directory. Within the contents, you can use curly The name of a file or directory. Within the contents, you can use curly
braces to indicate a "variable" part, for example:: 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 In the built documentation, the ``x`` will be displayed differently to
indicate that it is to be replaced by the Python minor version. indicate that it is to be replaced by the Python minor version.

View File

@ -3,7 +3,7 @@
import importlib import importlib
import traceback import traceback
import warnings 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.ext.autodoc.mock import ismock, undecorate
from sphinx.pycode import ModuleAnalyzer, PycodeError 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, from sphinx.util.inspect import (getannotations, getmro, getslots, isclass, isenumclass,
safe_getattr) safe_getattr)
if False: if TYPE_CHECKING:
# For type annotation
from typing import Type # NOQA
from sphinx.ext.autodoc import ObjectMember from sphinx.ext.autodoc import ObjectMember
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -28,10 +28,6 @@ else:
MethodDescriptorType = type(str.join) MethodDescriptorType = type(str.join)
WrapperDescriptorType = type(dict.__dict__['fromkeys']) WrapperDescriptorType = type(dict.__dict__['fromkeys'])
if False:
# For type annotation
from typing import Type # NOQA
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
memory_address_re = re.compile(r' at 0x[0-9a-f]{8,16}(?=>)', re.IGNORECASE) memory_address_re = re.compile(r' at 0x[0-9a-f]{8,16}(?=>)', re.IGNORECASE)

View File

@ -30,11 +30,6 @@ try:
except ImportError: except ImportError:
UnionType = None UnionType = None
if False:
# For type annotation
from typing import Type # NOQA # for python3.5.1
# builtin classes that have incorrect __module__ # builtin classes that have incorrect __module__
INVALID_BUILTIN_CLASSES = { INVALID_BUILTIN_CLASSES = {
Struct: 'struct.Struct', # Before Python 3.9 Struct: 'struct.Struct', # Before Python 3.9

View File

@ -111,6 +111,9 @@ def test_complex_assignment():
'f = g = None #: multiple assignment at once\n' 'f = g = None #: multiple assignment at once\n'
'(theta, phi) = (0, 0.5) #: unpack assignment via tuple\n' '(theta, phi) = (0, 0.5) #: unpack assignment via tuple\n'
'[x, y] = (5, 6) #: unpack assignment via list\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 = Parser(source)
parser.parse() parser.parse()
@ -124,22 +127,11 @@ def test_complex_assignment():
('', 'phi'): 'unpack assignment via tuple', ('', 'phi'): 'unpack assignment via tuple',
('', 'x'): 'unpack assignment via list', ('', 'x'): 'unpack assignment via list',
('', 'y'): 'unpack assignment via list', ('', 'y'): 'unpack assignment via list',
} ('', 'h'): 'unpack assignment2',
assert parser.definitions == {} ('', 'i'): 'unpack assignment2',
('', 'j'): 'unpack assignment2',
('', 'k'): 'unpack assignment3',
def test_complex_assignment_py3(): ('', 'l'): 'unpack assignment4',
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',
} }
assert parser.definitions == {} assert parser.definitions == {}