Skip to content

Commit 0a7a4d4

Browse files
Remove the space_check option and its code
1 parent 28a5c2e commit 0a7a4d4

File tree

4 files changed

+13
-60
lines changed

4 files changed

+13
-60
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Release date: TBA
1010

1111
Close #246, #289, #638, #747, #1148, #1179, #1943, #2041, #2301, #2304, #2944, #3565
1212

13+
* The no-space-check option has been removed. It's no longer possible to consider empty line like a `trailing-whitespace` by using clever options
14+
15+
Close #1368
1316

1417
What's New in Pylint 2.5.1?
1518
===========================

doc/whatsnew/2.6.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ New checkers
1616
Other Changes
1717
=============
1818

19-
* `bad-continuation` and `bad-whitespace` have been removed, `black` or another formatter can help you with this better than Pylint
19+
* `bad-continuation` and `bad-whitespace` have been removed. `black` or another formatter can help you with this better than Pylint
20+
21+
* The `no-space-check` option has been removed, it's no longer possible to consider empty line like a `trailing-whitespace` by using clever options.

pylint/checkers/format.py

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@
117117
_MUST_NOT = 1
118118
_IGNORE = 2
119119

120-
# Whitespace checking config constants
121-
_DICT_SEPARATOR = "dict-separator"
122-
_TRAILING_COMMA = "trailing-comma"
123-
_EMPTY_LINE = "empty-line"
124-
_NO_SPACE_CHECK_CHOICES = [_TRAILING_COMMA, _DICT_SEPARATOR, _EMPTY_LINE]
125-
_DEFAULT_NO_SPACE_CHECK_CHOICES = [_TRAILING_COMMA, _DICT_SEPARATOR]
126-
127120
MSGS = {
128121
"C0301": (
129122
"Line too long (%s/%s)",
@@ -301,24 +294,6 @@ class FormatChecker(BaseTokenChecker):
301294
),
302295
},
303296
),
304-
(
305-
"no-space-check",
306-
{
307-
"default": ",".join(_DEFAULT_NO_SPACE_CHECK_CHOICES),
308-
"metavar": ",".join(_NO_SPACE_CHECK_CHOICES),
309-
"type": "multiple_choice",
310-
"choices": _NO_SPACE_CHECK_CHOICES,
311-
"help": (
312-
"List of optional constructs for which whitespace "
313-
"checking is disabled. "
314-
"`" + _DICT_SEPARATOR + "` is used to allow tabulation "
315-
"in dicts, etc.: {1 : 1,\\n222: 2}. "
316-
"`" + _TRAILING_COMMA + "` allows a space between comma "
317-
"and closing bracket: (a, ). "
318-
"`" + _EMPTY_LINE + "` allows space-only lines."
319-
),
320-
},
321-
),
322297
(
323298
"max-module-lines",
324299
{
@@ -662,16 +637,13 @@ def check_line_ending(self, line: str, i: int) -> None:
662637
"""
663638
if not line.endswith("\n"):
664639
self.add_message("missing-final-newline", line=i)
665-
else:
666-
# exclude \f (formfeed) from the rstrip
667-
stripped_line = line.rstrip("\t\n\r\v ")
668-
if not stripped_line and _EMPTY_LINE in self.config.no_space_check:
669-
# allow empty lines
670-
pass
671-
elif line[len(stripped_line) :] not in ("\n", "\r\n"):
672-
self.add_message(
673-
"trailing-whitespace", line=i, col_offset=len(stripped_line)
674-
)
640+
return
641+
# exclude \f (formfeed) from the rstrip
642+
stripped_line = line.rstrip("\t\n\r\v ")
643+
if line[len(stripped_line) :] not in ("\n", "\r\n"):
644+
self.add_message(
645+
"trailing-whitespace", line=i, col_offset=len(stripped_line)
646+
)
675647

676648
def check_line_length(self, line: str, i: int) -> None:
677649
"""

tests/checkers/unittest_format.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -214,30 +214,6 @@ def testKeywordParensFalsePositive(self):
214214
class TestCheckSpace(CheckerTestCase):
215215
CHECKER_CLASS = FormatChecker
216216

217-
def testEmptyLines(self):
218-
self.checker.config.no_space_check = []
219-
with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
220-
self.checker.process_tokens(_tokenize_str("a = 1\n \nb = 2\n"))
221-
222-
with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
223-
self.checker.process_tokens(_tokenize_str("a = 1\n\t\nb = 2\n"))
224-
225-
with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
226-
self.checker.process_tokens(_tokenize_str("a = 1\n\v\nb = 2\n"))
227-
228-
with self.assertNoMessages():
229-
self.checker.process_tokens(_tokenize_str("a = 1\n\f\nb = 2\n"))
230-
231-
self.checker.config.no_space_check = ["empty-line"]
232-
with self.assertNoMessages():
233-
self.checker.process_tokens(_tokenize_str("a = 1\n \nb = 2\n"))
234-
235-
with self.assertNoMessages():
236-
self.checker.process_tokens(_tokenize_str("a = 1\n\t\nb = 2\n"))
237-
238-
with self.assertNoMessages():
239-
self.checker.process_tokens(_tokenize_str("a = 1\n\v\nb = 2\n"))
240-
241217
def test_encoding_token(self):
242218
"""Make sure the encoding token doesn't change the checker's behavior
243219

0 commit comments

Comments
 (0)