diff options
-rw-r--r-- | pylint/checkers/base.py | 8 | ||||
-rw-r--r-- | pylint/test/functional/deprecated_methods_py3.txt | 1 | ||||
-rw-r--r-- | pylint/test/functional/singleton_comparison.txt | 10 | ||||
-rw-r--r-- | pylint/test/unittest_checker_base.py | 24 |
4 files changed, 14 insertions, 29 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py index 2c918e722..52be3c3f8 100644 --- a/pylint/checkers/base.py +++ b/pylint/checkers/base.py @@ -2051,17 +2051,17 @@ class ComparisonChecker(_BasicChecker): def _check_singleton_comparison(self, singleton, root_node, negative_check=False): if singleton.value is True: if not negative_check: - suggestion = "just 'expr' or 'expr is True'" + suggestion = "just 'expr'" else: - suggestion = "just 'not expr' or 'expr is False'" + suggestion = "just 'not expr'" self.add_message( "singleton-comparison", node=root_node, args=(True, suggestion) ) elif singleton.value is False: if not negative_check: - suggestion = "'not expr' or 'expr is False'" + suggestion = "'not expr'" else: - suggestion = "'expr' or 'expr is not False'" + suggestion = "'expr'" self.add_message( "singleton-comparison", node=root_node, args=(False, suggestion) ) diff --git a/pylint/test/functional/deprecated_methods_py3.txt b/pylint/test/functional/deprecated_methods_py3.txt index ad588341d..53776b385 100644 --- a/pylint/test/functional/deprecated_methods_py3.txt +++ b/pylint/test/functional/deprecated_methods_py3.txt @@ -14,3 +14,4 @@ deprecated-method:44:Tests.test_foo:Using deprecated method assertNotEquals() deprecated-method:45:Tests.test_foo:Using deprecated method assertAlmostEquals() deprecated-method:46:Tests.test_foo:Using deprecated method assertNotAlmostEquals() deprecated-method:47:Tests.test_foo:Using deprecated method assert_() +c diff --git a/pylint/test/functional/singleton_comparison.txt b/pylint/test/functional/singleton_comparison.txt index c89b9c2f3..533d71f63 100644 --- a/pylint/test/functional/singleton_comparison.txt +++ b/pylint/test/functional/singleton_comparison.txt @@ -1,8 +1,8 @@ singleton-comparison:4::Comparison to None should be 'expr is None' -singleton-comparison:5::Comparison to True should be just 'expr' or 'expr is True' -singleton-comparison:6::Comparison to False should be 'not expr' or 'expr is False' -singleton-comparison:7::Comparison to True should be just 'expr' or 'expr is True' +singleton-comparison:5::Comparison to True should be just 'expr' +singleton-comparison:6::Comparison to False should be 'not expr' +singleton-comparison:7::Comparison to True should be just 'expr' singleton-comparison:11::Comparison to None should be 'expr is None' -singleton-comparison:13::Comparison to True should be just 'not expr' or 'expr is False' -singleton-comparison:14::Comparison to False should be 'expr' or 'expr is not False' +singleton-comparison:13::Comparison to True should be just 'not expr' +singleton-comparison:14::Comparison to False should be 'expr' singleton-comparison:15::Comparison to None should be 'expr is not None' diff --git a/pylint/test/unittest_checker_base.py b/pylint/test/unittest_checker_base.py index 8337c9c60..a1607cf8d 100644 --- a/pylint/test/unittest_checker_base.py +++ b/pylint/test/unittest_checker_base.py @@ -400,20 +400,12 @@ class TestComparison(CheckerTestCase): def test_comparison(self): node = astroid.extract_node("foo == True") - message = Message( - "singleton-comparison", - node=node, - args=(True, "just 'expr' or 'expr is True'"), - ) + message = Message("singleton-comparison", node=node, args=(True, "just 'expr'")) with self.assertAddsMessages(message): self.checker.visit_compare(node) node = astroid.extract_node("foo == False") - message = Message( - "singleton-comparison", - node=node, - args=(False, "'not expr' or 'expr is False'"), - ) + message = Message("singleton-comparison", node=node, args=(False, "'not expr'")) with self.assertAddsMessages(message): self.checker.visit_compare(node) @@ -427,11 +419,7 @@ class TestComparison(CheckerTestCase): node = astroid.extract_node("True == foo") messages = ( Message("misplaced-comparison-constant", node=node, args=("foo == True",)), - Message( - "singleton-comparison", - node=node, - args=(True, "just 'expr' or 'expr is True'"), - ), + Message("singleton-comparison", node=node, args=(True, "just 'expr'")), ) with self.assertAddsMessages(*messages): self.checker.visit_compare(node) @@ -439,11 +427,7 @@ class TestComparison(CheckerTestCase): node = astroid.extract_node("False == foo") messages = ( Message("misplaced-comparison-constant", node=node, args=("foo == False",)), - Message( - "singleton-comparison", - node=node, - args=(False, "'not expr' or 'expr is False'"), - ), + Message("singleton-comparison", node=node, args=(False, "'not expr'")), ) with self.assertAddsMessages(*messages): self.checker.visit_compare(node) |