Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PEP8 error in import line: E501 line too long

I have a python import string. PEP8 linter show to me E501 error line too long (82 > 79 characters):

from tornado.options import define, options, parse_config_file, parse_command_line

Solution with two line seems weird to me:

from tornado.options import define, options, parse_config_file
from tornado.options import parse_command_line

How I can fix it without disable E501 for this line?

like image 583
Vladimir Korshunov Avatar asked Dec 05 '22 16:12

Vladimir Korshunov


1 Answers

Put your imported names in parentheses, letting you span multiple lines:

from tornado.options import (
    define,
    options,
    parse_config_file,
    parse_command_line,
)

Using one line per name has the added advantage that later edits to the list of names imported reduce line churn (you can see what was added and removed in your version control system as separate lines).

like image 66
Martijn Pieters Avatar answered Dec 17 '22 12:12

Martijn Pieters