black/tests/data/preview
Antonio Ossa-Guerra d97b7898b3
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>
2022-11-11 20:05:36 -05:00
..
cantfit.py Wrap concatenated strings used as function args in parens (#3307) 2022-10-26 18:03:10 -07:00
comments7.py Add parens around implicit string concatenations where it increases readability (#3162) 2022-08-30 22:52:00 -04:00
comments8.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
comments9.py Enforce empty lines before classes/functions with sticky leading comments. (#3302) 2022-10-25 18:03:24 -07:00
docstring_preview.py Don't (ever) put a single-char closing docstring quote on a new line (#3166) 2022-07-13 22:26:05 -04:00
long_strings__edge_case.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
long_strings__regression.py Wrap concatenated strings used as function args in parens (#3307) 2022-10-26 18:03:10 -07:00
long_strings.py Wrap concatenated strings used as function args in parens (#3307) 2022-10-26 18:03:10 -07:00
one_element_subscript.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
percent_precedence.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
remove_await_parens.py Enforce empty lines before classes/functions with sticky leading comments. (#3302) 2022-10-25 18:03:24 -07:00
remove_except_parens.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
remove_for_brackets.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
remove_newline_after_code_block_open.py Remove newline after code block open (#3035) 2022-06-11 09:55:01 +03:00
return_annotation_brackets.py Remove hard coded test cases (#3062) 2022-05-18 12:11:37 -07:00
skip_magic_trailing_comma.py Correctly handle trailing commas that are inside a line's leading non-nested parens (#3370) 2022-11-09 15:08:51 -08:00
trailing_commas_in_leading_parts.py Correctly handle trailing commas that are inside a line's leading non-nested parens (#3370) 2022-11-09 15:08:51 -08:00
whitespace.py Remove whitespaces of whitespace-only files (#3348) 2022-11-11 20:05:36 -05:00