Skip to content

Commit

Permalink
Merge branch '1.7-release'
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jan 24, 2018
2 parents cfd9528 + 0a82ba0 commit f886f08
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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
--------
Expand Down
4 changes: 2 additions & 2 deletions sphinx/ext/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import sys
import time
import codecs
import platform
from os import path
import doctest

Expand Down Expand Up @@ -144,7 +143,8 @@ def run(self):
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:
Expand Down
9 changes: 6 additions & 3 deletions sphinx/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ def format_annotation(self, annotation):

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.
#
Expand All @@ -480,7 +481,8 @@ def format_annotation(self, annotation):
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
Expand All @@ -495,7 +497,8 @@ def format_annotation(self, annotation):
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__
Expand Down
3 changes: 2 additions & 1 deletion tests/test_ext_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import os
import re
import errno
import subprocess

import pytest
Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion tests/test_util_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ def test_Signature_annotations():

# TypeVars and generic types with TypeVars
sig = inspect.Signature(f2).format_args()
assert sig == '(x: List[T], y: List[T_co], z: T) -> List[T_contra]'
if sys.version_info < (3, 7):
sig == ('(x: typing.List[T], y: typing.List[T_co], z: T) -> '
'typing.List[T_contra]')
else:
sig == ('(x: typing.List[~T], y: typing.List[+T_co], z: T) -> '
'typing.List[-T_contra]')

# Union types
sig = inspect.Signature(f3).format_args()
Expand Down

0 comments on commit f886f08

Please sign in to comment.