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: Include end newlines in whitespace fix. #83043
Comments
Format => Strip Trailing Whitespace should strip extra newlines at the end of the file after stripping each line, and make sure that there is at least one. The latter is done when saving, and that code can be reused. |
patchcheck.py removes even a single newline if that is all that remains after stripping each line. So the revised rule is that a file should be either empty or end with a non-whitespace followed by a newline. My intent is that a file be ready to merge to out github python/cpython repository. |
Currently, iomenu.IOBinding.fixnewlines makes sure that when a non-empty non-Shell file is saved (and possibly run), it ends with at least 1 newline. At one time, I believe, compile needed this, and it is still good practice. (Git diffs note the absence of a final newline.) I originally planned to incorporate possible newline addition into do_rstrip, in anticipation of calling do_rstrip on save, but I have changed my mind, at least for the present. That code can stay where it is. If someone explicitly runs Strip Trailing Whitespace, adding a newline would sometimes be desired, but would sometimes be unexpected and possibly a nuisance. do_rstrip will ensure that non-Shell files end with at most 1 newline. My revised intent is that once we strip on save, saved files should be properly formatted for use or merging into a repository. |
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: