Merge branch '1.7' into 5298_imgmath_two_numbers

This commit is contained in:
Takeshi KOMIYA 2018-08-17 00:08:54 +09:00 committed by GitHub
commit 4b3fc81122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 0 deletions

View File

@ -28,6 +28,7 @@ Bugs fixed
font with XeLaTeX/LuaLateX (refs: #5251)
* #5280: autodoc: Fix wrong type annotations for complex typing
* autodoc: Optional types are wrongly rendered
* #5291: autodoc crashed by ForwardRef types
* #5298: imgmath: math_number_all causes equations to have two numbers in html
Testing

View File

@ -477,6 +477,8 @@ class Signature(object):
qualname = annotation._name
elif getattr(annotation, '__qualname__', None):
qualname = annotation.__qualname__
elif getattr(annotation, '__forward_arg__', None):
qualname = annotation.__forward_arg__
else:
qualname = self.format_annotation(annotation.__origin__) # ex. Union
elif hasattr(annotation, '__qualname__'):
@ -510,6 +512,8 @@ class Signature(object):
qualname = annotation._name
elif getattr(annotation, '__qualname__', None):
qualname = annotation.__qualname__
elif getattr(annotation, '__forward_arg__', None):
qualname = annotation.__forward_arg__
else:
qualname = self.format_annotation(annotation.__origin__) # ex. Union
elif hasattr(annotation, '__qualname__'):

View File

@ -297,6 +297,9 @@ def test_Signature_annotations():
sig = inspect.Signature(Node.children).format_args()
assert sig == '(self) -> List[typing_test_data.Node]'
sig = inspect.Signature(Node.__init__).format_args()
assert sig == '(self, parent: Optional[Node]) -> None'
def test_safe_getattr_with_default():
class Foo(object):

View File

@ -73,5 +73,8 @@ def f13() -> Optional[str]:
class Node:
def __init__(self, parent: Optional['Node']) -> None:
pass
def children(self) -> List['Node']:
pass