-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import statements should be after any shebang line #18
Comments
Taking into account #19, an import of a module that is not already imported at top-level should go:
|
(A module docstring is defined as a string at top-level that precedes any other code.) |
This only affects scripts; it can wait until the next release. |
I would say that this can be simplified to "just before any real Python code that is not merely a string". |
I think the ordering should be:
And any combination of the above can be omitted. I think the tricky thing is that it tries to add new imports at the end of the imports block, and that can go wrong if people mix other bits of code into their imports. |
@daira don't treat unicode strings as "merely a string" and that's it. |
mitsuhiko/python-modernize#30 was a duplicate (see also django-wiki/django-wiki#33 ). |
Addresses issue PyCQA#18 Imports are also placed after any comments (such as copyright notices), to be consistent with the existing import placement in files with module docstrings.
…space. Addresses issue PyCQA#18 Imports are already placed after copyright/comments if there's a docstring or shebang in the file. This makes import handling consistent in more cases.
Imports should only be added after any initial lines that are either blank or start with #. That would account for copyright headers etc., as well as shebang lines.
(moved from mitsuhiko/python-modernize#21 )
The text was updated successfully, but these errors were encountered: