Opened 8 years ago
Last modified 8 years ago
#27182 closed Cleanup/optimization
Some import statement use backslashes instead of parentheses — at Version 1
Reported by: | Chris Jerdonek | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Someday/Maybe | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Some import statements in Django's code base use backslashes to break long lines instead of parentheses (at least 21 occurrences if you search the code base for "import \
"). Here is one example (direct link here):
from django.db.backends.mysql.base import \ DatabaseWrapper as MySQLDatabaseWrapper
These go against Django's coding style standards, which say in the "Imports" section to use parentheses:
Break long lines using parentheses and indent continuation lines by 4 spaces.
Django's coding style also says to follow PEP 8, which says this:
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.
I believe this issue is caused by a bug in isort, since the isort section of Django's setup.cfg
already sets multi_line_output=5
(which means to use parentheses). I tried filing an issue about this here.