tox-dev / sphinx-autodoc-typehints

Type hints support for the Sphinx autodoc extension
MIT License
539 stars 101 forks source link

Every warning/error should provide useful context #238

Open anselor opened 2 years ago

anselor commented 2 years ago

Warnings/errors with generic messages do not provide context for what in the code caused the error.

Specifically, I ran into it here:

https://github.com/tox-dev/sphinx-autodoc-typehints/blob/bf27befb610426838d1f2926e470815c47cc8ab8/src/sphinx_autodoc_typehints/__init__.py#L343

I changed that log to also print guarded_code and it helped a lot. But I really think it should reraise the exception with the guarded_code and then catch and log it here with additional context:

https://github.com/tox-dev/sphinx-autodoc-typehints/blob/bf27befb610426838d1f2926e470815c47cc8ab8/src/sphinx_autodoc_typehints/__init__.py#L347

ewjoachim commented 1 year ago

when logging inside an except handler, it's often useful to include exc_info=True.