4

I have a function that accepts a dictionary as a parameter. This dictionary may contain keys that are used to configure how the function processes data. In docstring, I would like to specify which keys are acceptable. I am using PyCharm and its default reST/Sphinx docstring format, so I would like to be able to see the keys distinctively in the dialog that shows documentation after hovering the mouse over a function (shown below).

An example of how the function documentation looks after hovering the mouse over the function

The function could look like this:

from typing import Any

...

def process_data(data: list[Entry], dict_with_config: dict[str, Any]) -> list[ProcessedEntry]:
    """
    Docstring for the process_data function.

    :param data: Data to be processed.
    :param dict_with_config: A dictionary with configuration. Can accept the following keys:
        Here I would like to be able to show the acceptable keys in a distinctively.
    :returns: Processed data.
    :raises DataProcessingError: Some error when the data cannot be processed.
    """

    # ... process data according to the configuration dictionary

Is there a way to achieve what I want, so the acceptable keys are shown distinctively in the function help dialog?

Vaclav Pelc
  • 582
  • 6
  • 20

0 Answers0