Earlier quoted context omitted.
Function documentation goes inside functions in Python, explicitly making them self-documenting. That can then be automatically picked up by any other code (like tooling for automatically generating API documentation) formalized as PEP 257, https://peps.python.org/pep-0257 Python will literally assign the content of your docstring (a triple-quoted string at the start of a function) to a special double underscored ("d…
Annoyingly it pushes the type definitions away from the function body when you have a particularly long doc. It’s a cute trick but docs above would have been better.
It's not just a good trick: it's the right way to do it, and tooling can be (trivially) made to show you only what you need to see until you need to see more.