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.
Created on 2009年02月04日 08:37 by rhettinger, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| RstripExtension.py | roger.serwy, 2009年05月29日 00:05 | rstrip extension | ||
| ReindentExtension.py | roger.serwy, 2010年10月15日 23:28 | reindent.py extension | ||
| Messages (16) | |||
|---|---|---|---|
| msg81131 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2009年02月04日 08:37 | |
Add rstrip() to the Format menu. Python's svn repository no longer accepts files with trailing whitespace and it is often necessary to run reindent.py before submitting. It would be nice to have this as a built-in formatting tool. |
|||
| msg81301 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2009年02月06日 21:50 | |
If the interactive interpreter did not require blank lines within blocks to have at least one 'trailing' space to avoid prematurely ending the block (as when copy from editor window and paste), IDLE could automatically rstrip lines. Given that that should not be done, a menu item would be nice. |
|||
| msg88490 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2009年05月29日 00:05 | |
Here's an extension that adds rstrip() to the Format menu. |
|||
| msg88492 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2009年05月29日 01:23 | |
Applied in r72999. Will backport to 2.7. |
|||
| msg88495 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2009年05月29日 01:52 | |
Backported in r73001 |
|||
| msg91528 - (view) | Author: Guilherme Polo (gpolo) * (Python committer) | Date: 2009年08月13日 18:07 | |
This has been closed but why not promote reindent.py to a module and add an option on IDLE to allow a complete reindent.py run ? |
|||
| msg118808 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年10月15日 17:30 | |
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? |
|||
| msg118809 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年10月15日 17:39 | |
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. |
|||
| msg118847 - (view) | Author: Roger Serwy (roger.serwy) * (Python committer) | Date: 2010年10月15日 23:28 | |
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. ScriptBinding already has nice code to handle these problems by highlighting the error, placing the cursor at the error, and presenting a message box. Rather than duplicate this code, this extension makes calls into ScriptBinding to check for syntax errors when the core reindent code throws exceptions. |
|||
| msg122083 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年11月22日 03:27 | |
Opened back up for the new patch (posted after the previous close). |
|||
| msg216673 - (view) | Author: Ned Deily (ned.deily) * (Python committer) | Date: 2014年04月17日 08:27 | |
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. |
|||
| msg216678 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2014年04月17日 09:33 | |
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. #18704 was about integrating the pep8 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. |
|||
| msg260256 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2016年02月13日 23:27 | |
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. |
|||
| msg267059 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2016年06月03日 06:41 | |
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. '''\ line 1 line 2 ''' 'line with trailig space ' Indeed, the trick is needed to mark the trailing space in the code. I have thought about removing trailing spaces after each return, but pasting may be a problem. |
|||
| msg356845 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2019年11月18日 06:11 | |
reindent.py does the following: 1. Change Python (.py) files to use 4-space indents and no hard tab characters. IDLE editor does this by default, as do other programming editors, except as PEP8 recommends something else for continuation lines within fences <(), [], {}>. Before doing anything with reindent, I would want to check whether it messes with IDLE;s smart indents. 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? 2. Trim excess spaces and tabs from ends of lines. Format => strip whitespace, added on this issue, does this. (The code is now in the format module.) 3. Remove empty lines at the end of files. Rstrip should do this but does not. This is a separate issue from reindenting. 4. Ensure that the last line ends with a newline. Save in iomenu ensures this, but this should be part of 'strip whitespace', especially if we 'rstrip' on save (#33046). |
|||
| msg370827 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2020年06月06日 15:14 | |
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.) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:45 | admin | set | github: 49400 |
| 2020年06月06日 15:14:38 | terry.reedy | set | status: open -> closed title: IDLE to support reindent.py -> IDLE: add rstrip to Format menu messages: + msg370827 resolution: fixed stage: patch review -> resolved |
| 2019年11月18日 06:11:22 | terry.reedy | set | nosy:
+ taleinat messages: + msg356845 |
| 2016年06月03日 06:41:54 | terry.reedy | set | messages: + msg267059 |
| 2016年02月13日 23:27:22 | rhettinger | set | messages: + msg260256 |
| 2016年02月13日 11:59:30 | THRlWiTi | set | nosy:
+ THRlWiTi |
| 2014年04月17日 09:33:32 | terry.reedy | set | messages: + msg216678 |
| 2014年04月17日 08:27:37 | ned.deily | set | assignee: ned.deily -> stage: commit review -> patch review messages: + msg216673 versions: + Python 3.5, - Python 3.2 |
| 2012年03月25日 21:32:41 | asvetlov | set | nosy:
+ asvetlov |
| 2010年11月29日 01:52:07 | rhettinger | set | assignee: rhettinger -> ned.deily nosy: + ned.deily |
| 2010年11月26日 22:48:30 | terry.reedy | set | stage: resolved -> commit review resolution: fixed -> (no value) versions: + Python 3.2, - Python 3.1, Python 2.7 |
| 2010年11月22日 03:27:56 | rhettinger | set | status: closed -> open messages: + msg122083 |
| 2010年10月15日 23:28:11 | roger.serwy | set | files:
+ ReindentExtension.py messages: + msg118847 |
| 2010年10月15日 17:39:55 | rhettinger | set | messages: + msg118809 |
| 2010年10月15日 17:30:56 | eric.araujo | set | messages: + msg118808 |
| 2010年07月10日 19:38:36 | eric.araujo | set | nosy:
+ eric.araujo resolution: accepted -> fixed stage: needs patch -> resolved |
| 2009年08月13日 18:07:28 | gpolo | set | messages: + msg91528 |
| 2009年05月29日 01:52:33 | rhettinger | set | status: open -> closed messages: + msg88495 |
| 2009年05月29日 01:23:16 | rhettinger | set | assignee: kbk -> rhettinger resolution: accepted messages: + msg88492 |
| 2009年05月29日 00:05:15 | roger.serwy | set | files:
+ RstripExtension.py nosy: + roger.serwy messages: + msg88490 |
| 2009年04月26日 22:18:25 | ajaksu2 | set | nosy:
+ gpolo stage: needs patch |
| 2009年02月06日 21:50:38 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg81301 |
| 2009年02月04日 08:37:42 | rhettinger | create | |