This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Relax __all__ location requirement in PEP 8
Type: Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: IanLee1521, barry, docs@python, jayvdb, python-dev
Priority: normal Keywords:

Created on 2016-06-02 21:06 by barry, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue-27187-patch1.txt IanLee1521, 2016-06-03 00:20
issue-27187-patch2.txt IanLee1521, 2016-06-03 00:44 Updated patch that removes version bookkeeping section
issue-27187-patch3.txt IanLee1521, 2016-06-08 03:44 New patch explicitly mentioning ``__future__`` imports
Messages (9)
msg266949 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2016-06-02 21:06
PEP 8 says:

Put any relevant __all__ specification after the imports.

I don't remember why we wanted __all__ to go after imports.  I think we should relax that since other dunders can go before imports.

See related PYCQA issue: https://github.com/PyCQA/pycodestyle/issues/394
msg267002 - (view) Author: Ian Lee (IanLee1521) * Date: 2016-06-03 00:20
I think that it should be updated to specify that all dunders ('__all__', '__version__', '__author__', etc) should be placed after the module docstring and before any imports. See issue-27187-patch1.txt for a possible update.
msg267008 - (view) Author: Ian Lee (IanLee1521) * Date: 2016-06-03 00:31
I might also suggest that the entire "Version bookkeeping" section could be removed in this case, as it would be covered by my newly added dunder section.
msg267014 - (view) Author: Ian Lee (IanLee1521) * Date: 2016-06-03 00:59
I added a comment on a pull request related to this that shows some of the cases that we probably don't want to allow: https://github.com/PyCQA/pycodestyle/pull/523#issuecomment-223464775
msg267743 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-07 20:25
New changeset cf8e888b9555 by Barry Warsaw in branch 'default':
Relax __all__ location.
https://hg.python.org/peps/rev/cf8e888b9555
msg267744 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2016-06-07 20:26
Thanks for the patch!
msg267757 - (view) Author: John Mark Vandenberg (jayvdb) * Date: 2016-06-08 00:50
The revised text says __dunder__ should appear before any imports, however __future__ imports must appear first for obvious reasons.  Does this need to be mentioned in the pep?
msg267771 - (view) Author: Ian Lee (IanLee1521) * Date: 2016-06-08 03:44
Good catch.

I'm uploading a new patch that addresses ``from __future__`` imports issue explicitly.
msg267859 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2016-06-08 14:34
Thanks Ian.  I'm going to apply that, but rephrase it a bit.
History
Date User Action Args
2022-04-11 14:58:31adminsetgithub: 71374
2016-06-08 14:34:38barrysetmessages: + msg267859
2016-06-08 03:44:54IanLee1521setfiles: + issue-27187-patch3.txt
2016-06-08 03:44:08IanLee1521setmessages: + msg267771
2016-06-08 00:50:42jayvdbsetmessages: + msg267757
2016-06-07 20:26:13barrysetmessages: + msg267744
2016-06-07 20:25:26python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg267743

resolution: fixed
stage: resolved
2016-06-03 01:15:36jayvdbsetnosy: + jayvdb
2016-06-03 00:59:26IanLee1521setmessages: + msg267014
2016-06-03 00:44:51IanLee1521setfiles: + issue-27187-patch2.txt
2016-06-03 00:31:10IanLee1521setmessages: + msg267008
2016-06-03 00:20:06IanLee1521setfiles: + issue-27187-patch1.txt

messages: + msg267002
2016-06-02 21:14:06IanLee1521setnosy: + IanLee1521
2016-06-02 21:07:12barrysetassignee: docs@python

components: + Documentation
nosy: + docs@python
2016-06-02 21:06:42barrycreate