-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove whitespaces of whitespace-only files (#3348)
Currently, empty and whitespace-only (with or without newlines) are not modified. In some discussions (issues and pull requests) consensus was to reformat whitespace-only files to empty or single-character files, preserving line endings when possible. With that said, this commit introduces the following behaviors: * Empty files are left as is * Whitespace-only files (no newline) reformat into empty files * Whitespace-only files (1 or more newlines) reformat into a single newline character To implement these changes, we moved the initial check at `format_file_contents` that raises `NothingChanged` if the source (with no whitespaces) is an empty string. In the case of *.ipynb files, `format_ipynb_string` checks a similar condition and removed whitespaces. In the case of Python files, `format_str_once` includes a check on the output that returns the correct newline character if possible or an empty string otherwise. Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl>
- Loading branch information
Showing
4 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
|
||
|
||
|
||
# output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters