API Reference

Demo classes: Speaker and Greeting

This package contains minimal examples to demonstrate how Sphinx does and doesn’t allow you to handle circular imports in type hints, and where mypy may differ in its approach to the typing.TYPE_CHECKING conditional block versus sphinx-autodoc-typehints (which turns this flag on when set_type_checking_flag is set to True in docs/conf.py).


sphinx_demo provides a single class Speaker, with a method, set_new_greeting, which takes an instance of the class Greeting and stores it in the greeting attribute. This instance retains a reference to the ‘parent’ instance of class Speaker, creating a circular type reference which breaks the Sphinx build when using the sphinx-autodoc-typehints extension.

class sphinx_demo.greeting.Greeting(speaker, message='Hello ')[source]

Bases: object

greet()[source]
Return type

str

property name: str
Return type

str

property target: str
Return type

str

class sphinx_demo.speaker.Speaker(name='Testing')[source]

Bases: object

greet()[source]
Return type

str

set_new_greeting(greeting)[source]
Return type

None