personal web log written by izabeera and dryobates

reStructuredText typehints sphinx

Python3's typehints in Sphinx documenation

by dryobates

The most popular use for Python3's annotations are type hints. By default Sphinx can't use that type hints to document modules. Luckily for us Sphinx is easily extensible...

It was quickly obvious that after introduction of type hints there will quickly arose demand for Sphinx to be able extracting type information directly from code. Why to repeat ourselfs :)

I've found two such extensions:

  • sphinx-autodoc-annotation [1]
  • sphinx-autodoc-typehints [2]

I felt a little happier with latter one as it removes "type noise" from function signature into type section.

Both are easy to install so I encourage you to try it out.

Jakub Stolarski. Software engineer. I work professionally as programmer since 2005. Speeding up software development with Test Driven Development, task automation and optimization for performance are things that focus my mind from my early career up to now. If you ask me for my religion: Python, Vim and FreeBSD are my trinity ;) Email: