7

Is there a way for auto generating docstrings for dataclasses in the same fashion of the method and function docstrings? I did not find anything useful through help / search

from dataclasses import dataclass


@dataclass
class ExtractionConfig:
    """
    
    """
    gcp_bucket: str = None
    gcp_key: str = None
    log_file: str = None
    log_backup_count: int = 3
    delete_remotely: bool = True

When I try to manually add them, I get unresolved references:

unresolved refs

  • Note that @dataclass itself will already autogenerate it if one is not set: https://github.com/ericvsmith/dataclasses/pull/64 – wim Oct 14 '20 at 20:24
  • Can you show me how? –  Oct 14 '20 at 20:43
  • Related: https://stackoverflow.com/questions/6060813/how-to-document-fields-and-properties-in-python, https://stackoverflow.com/questions/51125415/how-do-i-document-a-constructor-for-a-class-using-python-dataclasses – Albert Jun 13 '22 at 08:20

1 Answers1

1

Pycharm does not support it at this moment.

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

bentos
  • 11
  • 1
  • In case it helps, there's a workaround, which is to add a docstring per field: https://youtrack.jetbrains.com/issue/PY-28549#focus=Comments-27-4299152.0-0 – Yul Kang Mar 26 '22 at 08:12