-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
IDLE: add rstrip to Format menu #49400
Comments
Add rstrip() to the Format menu. Python's svn repository no longer accepts files with trailing whitespace |
If the interactive interpreter did not require blank lines within blocks |
Here's an extension that adds rstrip() to the Format menu. |
Applied in r72999. Will backport to 2.7. |
Backported in r73001 |
This has been closed but why not promote reindent.py to a module and add |
reindent.py is very much a script: It lacks a nice, full programmatic API, I mean standalone functions to check a file object or a filename and functions implementing the command-line interface. As it is now, you see for example print calls in the middle of functions, so it’s not usable as a module. Maybe bring this to python-dev or -ideas? |
There's no need to go to python-dev or python-ideas with this one. If someone wants to figure-out a way to add reindent functionality to IDLE, patches are welcome. |
I grabbed the core of reindent.py and put it into an extension, unmodified. The original reindent.py will emit Indentation Errors if they exist. |
Opened back up for the new patch (posted after the previous close). |
The code needs to be updated for Python 3 and it needs a test. I'm deassigning it in the hopes that someone will feel free to pick it up. |
I use rstrip routinely when editing idlelib files, before committing, so it has been useful for that purpose. I do not happen to know what reindent.py does that the current format options do not. bpo-18704 was about integrating the PEP-8 style checker. That was closed in favor of adding a generic facility to run external analysis tools. There is not an open issue for that yet, but I expect it to happen, perhaps this summer. Reindent.py, if maybe improved, might be a candidate, though I will also try to look at the patch sometime. |
One other thought, it would be nice if there were an option (on by default) to automatically strip trailing whitespace when a file is saved. That would be much nicer than making the user remember to do periodic clean-ups as they edit. |
Having occasionally forgotten, and had to do whitespace commits, I agree. For Python code, there is never an absolute need for trailing whitespace. Trailing whitespace in string literals can be done by parse time concatenation. I have thought about removing trailing spaces after each return, but pasting may be a problem. |
reindent.py does the following:
The format module and Format menu has functions to add/remove tabs and changes space indents, as well as rewrap. The only thing left is dealing with a messed up file, but suspect that this is rarer than 19 (1st public version of reindent.py) or even 10 years ago (this issue). Is this issue still needed?
|
Adding rstrip as it was then was done over a decade ago, and this issue was closed then. Improvements, as discussed immediately above have been added with other issues, or will be. I am rejecting the add-on idea of incorporating reindent.py as unneeded. (It should have been a new issue instead of re-opening this one.) |
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: