From 0e5934b9ff0fe009263a5de961fc1d9186d889f8 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 21 Jan 2018 21:02:07 +0900 Subject: [PATCH 1/5] Fix #4472: DOCUMENTATION_OPTIONS is not defined --- CHANGES | 1 + sphinx/themes/basic/{ => static}/documentation_options.js_t | 0 2 files changed, 1 insertion(+) rename sphinx/themes/basic/{ => static}/documentation_options.js_t (100%) diff --git a/CHANGES b/CHANGES index ab9e4e10e..22a5f5936 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ Bugs fixed * #4415: autodoc classifies inherited classmethods as regular methods * #4415: autodoc classifies inherited staticmethods as regular methods +* #4472: DOCUMENTATION_OPTIONS is not defined Testing -------- diff --git a/sphinx/themes/basic/documentation_options.js_t b/sphinx/themes/basic/static/documentation_options.js_t similarity index 100% rename from sphinx/themes/basic/documentation_options.js_t rename to sphinx/themes/basic/static/documentation_options.js_t From ded638c82bfb92f6946dc422a62e1ed8b41cc2d2 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 25 Jan 2018 00:02:47 +0900 Subject: [PATCH 2/5] test: Add workaround for python 3.7.0a4+ Since 3.7.0a+, the behavior of typing module has been changed. As a result, format_annotation() also has been changed. --- tests/test_autodoc.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 462f65698..463f7735f 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -10,6 +10,7 @@ :license: BSD, see LICENSE for details. """ +import sys from six import PY3 from sphinx.testing.util import SphinxTestApp, Struct # NOQA @@ -1116,9 +1117,14 @@ def test_type_hints(): verify_arg_spec(f1, '(x: typing.List[int]) -> typing.List[int]') # TypeVars and generic types with TypeVars - verify_arg_spec(f2, '(x: typing.List[T],' - ' y: typing.List[T_co],' - ' z: T) -> typing.List[T_contra]') + if sys.version_info < (3, 7): + verify_arg_spec(f2, '(x: typing.List[T],' + ' y: typing.List[T_co],' + ' z: T) -> typing.List[T_contra]') + else: + verify_arg_spec(f2, '(x: typing.List[~T],' + ' y: typing.List[+T_co],' + ' z: T) -> typing.List[-T_contra]') # Union types verify_arg_spec(f3, '(x: typing.Union[str, numbers.Integral]) -> None') From 9340a4539394e1ae6a18b5d860dd7a45ec44bccf Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 25 Jan 2018 00:48:37 +0900 Subject: [PATCH 3/5] test: Don't use os.errno. Use errno directly --- tests/test_ext_math.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py index 9bbd6217d..1cdf4d637 100644 --- a/tests/test_ext_math.py +++ b/tests/test_ext_math.py @@ -11,6 +11,7 @@ import os import re +import errno import subprocess import pytest @@ -20,7 +21,7 @@ def has_binary(binary): try: subprocess.check_output([binary]) except OSError as e: - if e.errno == os.errno.ENOENT: + if e.errno == errno.ENOENT: # handle file not found error. return False else: From e01d076443850972b895a3a0051f6be5c05265e7 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 25 Jan 2018 00:56:26 +0900 Subject: [PATCH 4/5] Fix Signature does not work correctly with py37a4+ --- sphinx/util/inspect.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 5ed39906e..fd13d6fd6 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -453,7 +453,8 @@ class Signature(object): if annotation.__module__ == 'builtins': return annotation.__qualname__ # type: ignore - elif isinstance(annotation, typing.GenericMeta): + elif (hasattr(typing, 'GenericMeta') and # for py36 or below + isinstance(annotation, typing.GenericMeta)): # In Python 3.5.2+, all arguments are stored in __args__, # whereas __parameters__ only contains generic parameters. # @@ -480,7 +481,8 @@ class Signature(object): if params is not None: param_str = ', '.join(self.format_annotation(p) for p in params) return '%s[%s]' % (qualified_name, param_str) - elif (isinstance(annotation, typing.CallableMeta) and # type: ignore + elif (hasattr(typing, 'CallableMeta') and # for py36 or below + isinstance(annotation, typing.CallableMeta) and # type: ignore getattr(annotation, '__args__', None) is not None and hasattr(annotation, '__result__')): # Skipped in the case of plain typing.Callable @@ -495,7 +497,8 @@ class Signature(object): return '%s[%s, %s]' % (qualified_name, args_str, self.format_annotation(annotation.__result__)) - elif (isinstance(annotation, typing.TupleMeta) and # type: ignore + elif (hasattr(typing, 'TupleMeta') and # for py36 or below + isinstance(annotation, typing.TupleMeta) and # type: ignore hasattr(annotation, '__tuple_params__') and hasattr(annotation, '__tuple_use_ellipsis__')): params = annotation.__tuple_params__ From 0a82ba00b58c3da95182e0cbc76b2ce51d42e0d6 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 25 Jan 2018 01:25:55 +0900 Subject: [PATCH 5/5] Fix packaging module can't handle 3.7.0a4+ correctly --- sphinx/ext/doctest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index cd35e789a..d0614718b 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -15,7 +15,6 @@ import re import sys import time import codecs -import platform from os import path import doctest @@ -144,7 +143,8 @@ class TestDirective(Directive): if self.name == 'doctest' and 'pyversion' in self.options: try: spec = self.options['pyversion'] - if not is_allowed_version(spec, platform.python_version()): + python_version = '.'.join(str(v) for v in sys.version_info[:3]) + if not is_allowed_version(spec, python_version): flag = doctest.OPTIONFLAGS_BY_NAME['SKIP'] node['options'][flag] = True # Skip the test except InvalidSpecifier: