pep8在具有参数列表和赋值的长行上的正确缩进是什么

时间:2016-01-18 16:44:56

标签: python django pep8

此方案的正确缩进是什么:

class StorageType(models.Model):
    """ Defining a general typ of storage """

    name = models.CharField(
            max_length=50,
            help_text=_("The name for a storage type. Should be unique")
        )

pep8抱怨

../models.py:68:13: E126 continuation line over-indented for hanging indent
../models.py:70:9: E121 continuation line under-indented for hanging indent

2 个答案:

答案 0 :(得分:6)

我不知道"正确的一个",但这是我最喜欢的通过pep8检查:

name = models.CharField(
    max_length=50,
    help_text=_("The name for a storage type. Should be unique")
)

答案 1 :(得分:5)

这是一个正确的缩进:

class StorageType(models.Model):
    """ Defining a general typ of storage """

    name = models.CharField(
        max_length=50,
        help_text=_("The name for a storage type. Should be unique")
        )