msg273892 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-08-30 01:46 |
PEP 8 suggests separately grouping stdlib, dependency, and local package imports. Within idlelib, idlelib imports are treated as local package imports. Tkinter is sometimes treated as a dependency, which makes its imports easy to notice, and I want to do this consistently. It is conventional to sort imports within each group. This is sometimes true now, sometimes not (even before the 3.6 renaming). The possible danger of rearranging imports is that a line gets deleted and not pasted. Rietveld's side-by-side diff should make this easy to detect. This issue is about re-arranging the imports currently at the top of a file, and any module level imports that I notice elsewhere. Dealing with delayed imports within functions and classed will be another issue, which will depend on this one. |
|
|
msg273895 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-08-30 02:16 |
This issue includes adding the idlelib import coding standard to idlelib.README. The delayed-import issue is #27893. A second followup will be to stop importing tkinter modules 'as' their Py 2 names. Change "from tkinter import font as TkFont" to "from tkinter import font" and globally replace 'TkFont' with 'tkfont'. Do the same for messagebox and any other submodules as needed. |
|
|
msg273897 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-08-30 03:07 |
On 2002 Sept 14, the following was merged into editor.py (then EditorWindow.py) as part of the smart indenting code added to the bottom. import tokenize _tokenize del tokenize This now would usually be written "import tokenize as _tokenize". Stdlib modules without explicit __all__ often do this to omit stdlib modules from their public interface. Idlelib does not do this. Add to README import standards. I put replaced the above with 'import tokenize' as the top where is belongs and changed all '_tokenize' to 'tokenize'. |
|
|
msg273905 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-08-30 08:40 |
Part of previous message should be 'at the top where it belongs'. With attached patch, each file compiles and (incomplete) tests pass. Will examine each with side-by-side diff. There might be artifacts from another patch left. |
|
|
msg273906 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-08-30 08:44 |
Followup is #27892 |
|
|
msg273994 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-08-31 03:37 |
Patch 2 has minor revisions to hyperparser, mainmenu, pyshell, and adds material to README.txt. |
|
|
msg274000 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-08-31 04:51 |
New changeset 96ac4cd43a20 by Terry Jan Reedy in branch 'default': Issue #27891: Consistently group and sort imports within idlelib modules. https://hg.python.org/cpython/rev/96ac4cd43a20 |
|
|
msg274078 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-08-31 23:37 |
New changeset 28ce37a2d888 by Terry Jan Reedy in branch 'default': Issue #27891: Tweak new idlelib README entry. https://hg.python.org/cpython/rev/28ce37a2d888 |
|
|