I contacted support and it turns out it hasn't been implemented.

I have created a feature request on their issue tracker:

https://youtrack.jetbrains.com/issue/PY-14743

Update:

original feature request is marked as a duplicate of

https://youtrack.jetbrains.com/issue/PY-27635

State: In progress

Answer from gak on Stack Overflow
Top answer
1 of 1
5

I want to link to other methods / functions / classes from some of the docstrings, but I cannot figure out how to do this.

You're correct that the reStructuredText documentation does not cover this, because it's not a feature of reStructuredText.

Likely you are (explicitly, or implicitly via some tool) using the Sphinx system – a superset of Docutils – to allow (among many other features) references between different docstrings.

Sphinx defines several Docstring “roles” (the :foo: before the backtick-quoted text) for different purposes:

  • doc, a reference to an entire document.
  • ref, an arbitrary cross-reference.
  • … many others.

For specifically Python code, the “domain” py has its own specific set of roles for Python code docstrings:

  • :py:mod:

    Reference a module; a dotted name may be used. This should also be used for package names.

  • :py:func:

    Reference a Python function; dotted names may be used. The role text needs not include trailing parentheses to enhance readability; they will be added automatically by Sphinx if the add_function_parentheses config value is True (the default).

  • :py:data:

    Reference a module-level variable.

  • :py:const:

    Reference a “defined” constant. This may be a Python variable that is not intended to be changed.

  • :py:class:

    Reference a class; a dotted name may be used.

  • :py:meth:

    Reference a method of an object. The role text can include the type name and the method name; if it occurs within the description of a type, the type name can be omitted. A dotted name may be used.

  • :py:attr:

    Reference a data attribute of an object.

  • :py:exc:

    Reference an exception. A dotted name may be used.

  • :py:obj:

    Reference an object of unspecified type.

🌐
JetBrains
jetbrains.com › help › pycharm › creating-documentation-comments.html
Create documentation comments | PyCharm Documentation
August 14, 2026 - Open settings Ctrl+Alt+S and navigate to Python | Tools | Integrated Tools. In the Docstring format dropdown, select reStructuredText. Then type the opening triple double-quotes and press Enter or Space. PyCharm generates a documentation comment stub in reStructuredText format: """ :param self: :param myParam1: :param myParam2: :return: """ You can use markup for text formatting, as well as substitutions, bulleted lists, links, code blocks, and tables.
Top answer
1 of 4
4

The PyCharm support told me the following :

As PyCharm developer said: You cannot distinguish classes and instances in type hints. The name of a class in a type hint means that an instance of that class is expected. If your function accepts the class itself, your options are either not to use type hints at all or use the 'type' as a class name. Anyway, there won't be any useful code completion in these cases. See also https://youtrack.jetbrains.com/issue/PY-11615.

The only way to specificate an argument is a class is to use :type arg: type, but the completion won't work well. There is no other way currently.

2 of 4
1

If you want to specify that a parameter is of type SomeClass, it should be declared as such:

@type (param): SomeClass

Specified properly, you should get something like this:

If you don't specify the type of the parameter properly:

At this point, I figured I would dig a little deeper to see if I could find anything interesting. If you go to the declaration of an object's .__class__, you'll be directed here (in builtins.py):

Perhaps __class__ was set to None? Even if it is by default but then updated when the class gets instantiated (which would be my guess as to what happens), this might be what PyCharm infers __class__ resolves to. All of this is just speculation on my end and may as well be incorrect, but... Just for the heck of it, what behavior can we see if we set a parameter's type to None, then?

Looks like the same thing that happened when we set the type to SomeClass.__fake__ (and I tested it with SomeClass.__class__, and the same thing happens there too.)

So I suppose the question at hand is, why can't you use @type cinstance: Bar?

🌐
JetBrains
youtrack.jetbrains.com › issue › PY-35223 › be-able-to-reference-function-class-in-docstring
be able to reference function/class in docstring : PY-35223
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
🌐
JetBrains
jetbrains.com › help › pycharm › settings-tools-python-integrated-tools.html
Integrated Tools | PyCharm Documentation
July 19, 2026 - Use this page to configure requirements management file, default test runner, and documentation strings treatment.
🌐
JetBrains
jetbrains.com › help › pycharm › using-docstrings-to-specify-types.html
Specify types with docstrings | PyCharm Documentation
September 1, 2025 - import math class SimpleEquation: def demo(self, a, b, c): d = math.sqrt(abs(b ** 2 - 4 * a * c)) root1 = (-b + d) / (2 * a) root2 = (-b - d) / (2 * a) return root1, root2 SimpleEquation().demo(3, 2, 1) Place the caret at the name of the function (here it is demo). The suggested intention action is Insert documentation string stub. For more information, refer to Create documentation comments.
🌐
Medium
medium.com › @djnrrd › automatic-documentation-with-pycharm-70d37927df57
Automatic Documentation with PyCharm | by DJ Nrrd | Medium
April 21, 2020 - Admittedly, the sphinx info fields aren’t as easy to look at here as other docstring formats and standards, but all the info you would normally have provided in a docstring is there. As you start doing this you’ll see that PyCharm starts to use this information to generate mouse-over hint windows, which you can add to the side bar. ... I’m heavily into object orientated python, maybe too much, but if you want to document the arguments to your classes, make sure the info fields are in the docstring of the class and not the ‘__init__’ function.
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-22175 › Not-able-to-reference-other-functions-in-my-docstrings-with-a-link
Not able to reference other functions in my docstrings with ...
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions.
Find elsewhere
🌐
JetBrains
jetbrains.com › help › pycharm › type-syntax-for-docstrings.html
Legacy type syntax for docstrings | PyCharm Documentation
March 18, 2026 - Thus, PyCharm suggests the following notation: Consider adding information about the expected type of a local variable using :type or @type docstrings: It is also possible to use isinstance to define the expected local variable type: You can use type hinting to specify the expected type of fields: Alternatively, you can specify types of fields in the docstring of a class...
🌐
JetBrains
jetbrains.com › help › pycharm › inline-documentation.html
Viewing Inline Documentation | PyCharm Documentation
March 6, 2026 - The Documentation popup helps navigate to the related symbols via hyperlinks, and provides a toolbar for moving back and forth through the already navigated pages, changing font size, and viewing documentation in an external browser.
🌐
JetBrains
jetbrains.com › pycharm › guide › tutorials › sphinx_sites › documentation
Documenting Code - JetBrains Guide
February 17, 2023 - We can also use role-based syntax, with the Python domain as a prefix: This comes with an extra benefit, as link text is provided for you: As we can see in {py:class}`my_demo.MyDemo`, Python is fun!
🌐
JetBrains
jetbrains.com › help › pycharm › generating-reference-documentation.html
Generate reference documentation | PyCharm Documentation
August 4, 2025 - Add docstrings to your Python functions, classes, or exceptions in the source code.
🌐
JetBrains
jetbrains.com › help › pycharm › documenting-source-code.html
Document source code | PyCharm Documentation
January 20, 2026 - In the Python files, PyCharm recognizes the documentation comments represented as Python docstrings. Before you start, make sure that the required docstring format is selected in the Integrated Tools page of the Settings dialog.
🌐
Sololearn
sololearn.com › en › Discuss › 2411066 › docstrings-in-pycharm
Sololearn: Learn to Code
July 24, 2020 - Select the quotes so that the code assistant light bulb shows, click the down arrow and choose the option to change to double quotes. This will give you a Docstring according to your settings. ... No, that is the default. Mine is the same. https://www.jetbrains.com/help/pycharm/settings-tools-JUMP_LINK__&&__python__&&__JUMP_LINK-integrated-tools.html
🌐
Quora
quora.com › How-do-you-write-a-docstring-in-PyCharm
How to write a docstring in PyCharm - Quora
Answer: PyCharm is just an editor l! Docstrings are a feature of Python so to write a doc string you apply the following rules : * Doc strings immediately follow the start of a module, class or method - in the case of a class or method they should be the next thing after the class or def state...
🌐
JetBrains
jetbrains.com › help › pycharm › viewing-reference-information.html
Code reference information | PyCharm Documentation
August 18, 2026 - This section describes how to see definitions of symbols, display documentation references, and use the view parameter information feature. The Parameter Info popup shows the names of parameters in method and function calls. PyCharm automatically shows a popup with all available method signatures within 1 second (1000 milliseconds) after you type an opening bracket in the editor, or select a method from the suggestion list.