Search code examples
pythonpython-2.7pycharmpython-sphinxdocstring

Python 2 type code-completion in JetBrains?


class A:
  """
  A

  Attributes:
      type (int): type field
      required ([str]): required field
  """

  type = None  # type: str
  required = None  # type: [str]

  def __init__(self, type, required):
    """
    The constructor for A class.

    Parameters:
       type (int): type field
       required ([str]): required field
    """

    self.type = type
    self.required = required

Which works for strings: <code>A().type.</code>

But not lists: <code>A().required.</code>


Solution

  • The answer you want is # type: list[str].