IntelliJ IDEA 2017.2 Help

Using Docstrings to Specify Types

The following is only valid when Python Plugin is installed and enabled!

On this page:


You debug your code permanently, and now in course of debugging you can also collect type information and specify these types in docstrings.

IntelliJ IDEA provides an intention action that makes it possible to collect type information at runtime, and define type specifications.

However, it is quite possible to specify the types of parameters manually, without the debugger.

Both cases are explored in the section Examples.


Make sure that the check box Insert type placeholders in the Smart Keys page of the editor settings is selected.

Note also, that reStructuredText is used for all the subsequent examples, but it is possible to use any of the supported formats of the documentation strings, whether it is plain text, Epytext, Google or NumPy. Refer to the description of the page Python Integrated Tools for details.

Parameter type specification

To specify the parameter types, follow these general steps

  1. Place the caret at the function name, and press Alt+Enter.
  2. In the list of intention actions that opens, choose Insert documentation string stub. IntelliJ IDEA creates a documentation stub, according to the selected docstring format, with the type specification, collected during the debugger session.
Last modified: 29 November 2017

See Also

Language and Framework-Specific Guidelines: