Less-than sign in python parameter docstring not showing up in PyCharm

Viewed 265

I have a simple function that I document like this:

def fun(x):
    """
    My function

    :param x: 0 <= x <= 1, blah blah
    """
    pass

Unfortunately, in PyCharm, if I either hit Ctrl-Q or just hover over the function, the documentation box that pops up is missing the < signs. Instead the box just says Params -- 0 = x = 1, blah blah. Trying to escape the < doesn't help. Anyone know a fix?

On edit: thanks to @Marat, the issue is that PyCharm uses HTML for the :param part of the doc string but not for the main body of the doc string. So this means that to get everything to show up correctly, I would do something like this:

def fun(x):
    """
    My function (make sure 0 <= x <= 1)

    :param x: 0 &lt= x &lt= 1, blah blah
    """
    pass

But then help(fun) will show up wrong, but looks like this is as good as it gets.

1 Answers

It looks like a bug/feature in PyCharm. Apparently it supports HTML in docstrings, replacement of < with &lt; fixes the problem.

UPD: HTML is only supported in param/returns/data strings, including Google-style definitions (Args: ...). Still not sure if it is a bug or a feature.

Related