Skip to content

Commit

Permalink
Merge pull request #5309 from tk0miya/5306_NameError_for_invalid_type…
Browse files Browse the repository at this point in the history
…hints

Fix #5306: autodoc: ``getargspec()`` raises NameError for invalid typehints
  • Loading branch information
tk0miya committed Aug 17, 2018
2 parents 2604920 + a450eb7 commit e623739
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions sphinx/ext/autodoc/inspector.py
Expand Up @@ -130,8 +130,11 @@ def get_annotation(name):
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('(')
Expand Down

0 comments on commit e623739

Please sign in to comment.