mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
commit
e623739eff
1
CHANGES
1
CHANGES
@ -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
|
||||
|
@ -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('(')
|
||||
|
Loading…
Reference in New Issue
Block a user