[Python] Why are my function parameters in PyCharm docstrings displayed twice?

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    This is what my function looks like:

    def convert_lesions(input_lesions: list, output: str) -> list:
    """
    Convert a list of IDs/class names to a list of corresponding IDs, names, or colors.
    Args:
    input_lesions: Either class names or IDs.
    output: Expected output format. Possible values are 'ids', 'names', or 'colors'.
    Returns:
    List of class IDs, names or list of colors corresponding to the input list.
    """
    conversion_map = {
    'ids': lambda lst: [key for key, value in LESIONS['classes'].items() if value in lst],
    'names': lambda lst: [LESIONS['classes'][class_id] for class_id in lst if class_id in LESIONS['classes']],
    'colors': lambda lst: [LESIONS['colors'][class_id] for class_id in lst if class_id in LESIONS['colors']]}
    return conversion_map[output](input_lesions)


    However, as can be seen in the text below, the parameters that appear when I move the mouse into the function name are displayed twice: both in the entire content of the docstrings and later as the parameters and output of the function, separately.

    def convert_lesions(input_lesions: Any,
    output: Any) -> Any

    Convert a list of IDs/class names to a list of corresponding IDs, names, or colors.

    Args: input_lesions: Either class names or IDs.

    output: Expected output format. Possible values are 'ids', 'names', or 'colors'.

    Returns: List of class IDs, names or list of colors corresponding to the input list.

    Params:

    input_lesions – Either class names or IDs.

    output – Expected output format. Possible values are 'ids', 'names', or 'colors'.

    Returns:

    List of class IDs, names or list of colors corresponding to the input list.


    Meanwhile, I would like the function preview to show an explanation of the function, with Parameters and Returns properly highlighted below, like this:

    def convert_lesions(input_lesions: Any,
    output: Any) -> Any

    Convert a list of IDs/class names to a list of corresponding IDs, names, or colors.

    Params:

    input_lesions – Either class names or IDs.

    output – Expected output format. Possible values are 'ids', 'names', or 'colors'.

    Returns:

    List of class IDs, names or list of colors corresponding to the input list.


    How can I achieve this format?

    My PyCharm version is 2023.3.5 (Professional).

    //Edit: as for now (2025), it was finally fixed, yay!

    Continue reading...

Compartilhe esta Página