-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Consistently group and sort imports within idlelib modules. #72078
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
Comments
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. |
This issue includes adding the idlelib import coding standard to idlelib.README. The delayed-import issue is bpo-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. |
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'. |
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. |
Followup is bpo-27892 |
Patch 2 has minor revisions to hyperparser, mainmenu, pyshell, and adds material to README.txt. |
New changeset 96ac4cd43a20 by Terry Jan Reedy in branch 'default': |
New changeset 28ce37a2d888 by Terry Jan Reedy in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: