Line is too long. Django PEP8

前端 未结 6 981
余生分开走
余生分开走 2021-02-01 04:09

PEP8 info:

models.py:10:80: E501 line too long (83 > 79 characters)

Models.py:

field = TreeForeignKey(\'self\', null         


        
6条回答
  •  天涯浪人
    2021-02-01 04:58

    It's "correct", PEP8 just flags lines over 79 characters long. But if you're concerned about that, you could write it like this:

    field = TreeForeignKey('self',
                           null=True,
                           blank=True,
                           related_name='abcdefgh')
    

    Or this:

    field = TreeForeignKey(
        'self',
        null=True,
        blank=True,
        related_name='abcdefgh',
    )
    

    Or, really, any other style that would break the single line into multiple shorter lines.

提交回复
热议问题