Skip to content

Commit

Permalink
Remove the space_check option and its code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed May 3, 2020
1 parent bbc849e commit b1e7a90
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 60 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Release date: TBA

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

* The no-space-check option has been removed. It's no longer possible to consider empty line like a `bad-whitespace` by using clever options

Close #1368

What's New in Pylint 2.5.1?
===========================
Expand Down
4 changes: 3 additions & 1 deletion doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ New checkers
Other Changes
=============

* `bad-continuation` and `bad-whitespace` have been removed, `black` or another formatter can help you with this better than Pylint
* `bad-continuation` and `bad-whitespace` have been removed. `black` or another formatter can help you with this better than Pylint

* The `no-space-check` option has been removed, it's no longer possible to consider empty line like a `bad-whitespace` by using clever options.
42 changes: 7 additions & 35 deletions pylint/checkers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@
_MUST_NOT = 1
_IGNORE = 2

# Whitespace checking config constants
_DICT_SEPARATOR = "dict-separator"
_TRAILING_COMMA = "trailing-comma"
_EMPTY_LINE = "empty-line"
_NO_SPACE_CHECK_CHOICES = [_TRAILING_COMMA, _DICT_SEPARATOR, _EMPTY_LINE]
_DEFAULT_NO_SPACE_CHECK_CHOICES = [_TRAILING_COMMA, _DICT_SEPARATOR]

MSGS = {
"C0301": (
"Line too long (%s/%s)",
Expand Down Expand Up @@ -301,24 +294,6 @@ class FormatChecker(BaseTokenChecker):
),
},
),
(
"no-space-check",
{
"default": ",".join(_DEFAULT_NO_SPACE_CHECK_CHOICES),
"metavar": ",".join(_NO_SPACE_CHECK_CHOICES),
"type": "multiple_choice",
"choices": _NO_SPACE_CHECK_CHOICES,
"help": (
"List of optional constructs for which whitespace "
"checking is disabled. "
"`" + _DICT_SEPARATOR + "` is used to allow tabulation "
"in dicts, etc.: {1 : 1,\\n222: 2}. "
"`" + _TRAILING_COMMA + "` allows a space between comma "
"and closing bracket: (a, ). "
"`" + _EMPTY_LINE + "` allows space-only lines."
),
},
),
(
"max-module-lines",
{
Expand Down Expand Up @@ -662,16 +637,13 @@ def check_line_ending(self, line: str, i: int) -> None:
"""
if not line.endswith("\n"):
self.add_message("missing-final-newline", line=i)
else:
# exclude \f (formfeed) from the rstrip
stripped_line = line.rstrip("\t\n\r\v ")
if not stripped_line and _EMPTY_LINE in self.config.no_space_check:
# allow empty lines
pass
elif line[len(stripped_line) :] not in ("\n", "\r\n"):
self.add_message(
"trailing-whitespace", line=i, col_offset=len(stripped_line)
)
return
# exclude \f (formfeed) from the rstrip
stripped_line = line.rstrip("\t\n\r\v ")
if line[len(stripped_line) :] not in ("\n", "\r\n"):
self.add_message(
"trailing-whitespace", line=i, col_offset=len(stripped_line)
)

def check_line_length(self, line: str, i: int) -> None:
"""
Expand Down
24 changes: 0 additions & 24 deletions tests/checkers/unittest_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,30 +214,6 @@ def testKeywordParensFalsePositive(self):
class TestCheckSpace(CheckerTestCase):
CHECKER_CLASS = FormatChecker

def testEmptyLines(self):
self.checker.config.no_space_check = []
with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
self.checker.process_tokens(_tokenize_str("a = 1\n \nb = 2\n"))

with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
self.checker.process_tokens(_tokenize_str("a = 1\n\t\nb = 2\n"))

with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
self.checker.process_tokens(_tokenize_str("a = 1\n\v\nb = 2\n"))

with self.assertNoMessages():
self.checker.process_tokens(_tokenize_str("a = 1\n\f\nb = 2\n"))

self.checker.config.no_space_check = ["empty-line"]
with self.assertNoMessages():
self.checker.process_tokens(_tokenize_str("a = 1\n \nb = 2\n"))

with self.assertNoMessages():
self.checker.process_tokens(_tokenize_str("a = 1\n\t\nb = 2\n"))

with self.assertNoMessages():
self.checker.process_tokens(_tokenize_str("a = 1\n\v\nb = 2\n"))

def test_encoding_token(self):
"""Make sure the encoding token doesn't change the checker's behavior
Expand Down

0 comments on commit b1e7a90

Please sign in to comment.