docstring code block indentation

I have  a python function whose docstring has an example dictionary.  When I hover over the function name, the quick documentation pops up but the indentation of the dictionary has been stripped, leaving all lines at the left margin.  I'd like it to display as typed, as a code block or literal block.

After searching the docs, I've tried various things including preceding the dict with a line ending with ‘::’, then a blank line, then indenting the dict, such as:

def myfunc(args):
    """I have a docstring with a dict.

    For example::

        mydict = {
            "key1": val1,
            "key2": val2,
        }

    Yada yada.
    """
    return args

    

Then the quick documentation shows the following, stripping my leading indentation.

 

Are there PyCharm settings to control this behavior? 

Or is there something else I need to do to indicate ‘code block' ?

PyCharm 2024.1.1 (Professional Edition)
Build #PY-241.15989.155, built on April 29, 2024

1
1 comment

It seem's to me that this got fixed. At least, your example is indented correctly in IntelliJ IDEA 2025.3.3 (Build #IU-253.31033.145) with Python plugin 253.31033.145

0

Please sign in to leave a comment.