Merge pull request #5309 from tk0miya/5306_NameError_for_invalid_typehints

Fix #5306: autodoc: ``getargspec()`` raises NameError for invalid typehints
This commit is contained in:
Takeshi KOMIYA authored and GitHub committed 2018-08-17 22:10:56 +09:00
commit e623739eff
2 files changed
+6 -2

No files matched your search

+1
View File
@@ -30,6 +30,7 @@ Bugs fixed
* autodoc: Optional types are wrongly rendered
* #5291: autodoc crashed by ForwardRef types
* #5211: autodoc: No docs generated for functools.partial functions
* #5306: autodoc: ``getargspec()`` raises NameError for invalid typehints
* #5298: imgmath: math_number_all causes equations to have two numbers in html
Testing
+5 -2
View File
@@ -130,8 +130,11 @@ def formatargspec(function, args, varargs=None, varkw=None, defaults=None,
else:
return value
introspected_hints = (typing.get_type_hints(function) # type: ignore
if typing and hasattr(function, '__code__') else {})
try:
introspected_hints = (typing.get_type_hints(function) # type: ignore
if typing and hasattr(function, '__code__') else {})
except Exception:
introspected_hints = {}
fd = StringIO()
fd.write('(')