diff options
author | Jaehoon Hwang <jaehoonhwang@users.noreply.github.com> | 2021-10-23 05:52:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-23 14:52:23 +0200 |
commit | 8b60e428457fb1125f61bd97296665aef53eefb8 (patch) | |
tree | 52d4cfa002f6177870296e4bba13890ec06ae6a3 /tests/checkers | |
parent | 772b3dcc0b0770a843653783e5c93b4256e5ec6f (diff) | |
download | pylint-git-8b60e428457fb1125f61bd97296665aef53eefb8.tar.gz |
Fix use-implicit-booleaness-not-comparison crash (#5176)
* Fix use-implicit-booleaness-not-comparison crash
`use-implicit-booleaness-not-comparison` caused a crash due to
`target_node` not being an instance of `NodeNG.Name`
This fix will allow the checker to have a default handling when it
encounters `target_node` other than `Calls`,`Name`, or `Attribute`
* Added more comprehensive test for implicit_booealness_checker
* Make implicit_booealness_checker to have default `variable_name`
* Handle `Calls`,`Name`, or `Attribute`
* Fix typing in ImplicitBooleanessChecker.base_classes_of_node
* [implicit-booleaness] Add call nodes name in warnings
* Use `BaseContainer` to check for empty tuple/list and use `as_string` for `Attribute` and `Name` nodes for message
Using `BaseContainer` for checking for empty `tuple` and `list`.
In addition, `is_base_container` checks for `FrozenSet` and `Set` as
well.
* Update test cases with cr concerns
* Use `BaseContainer` when checking for empty list or tuple
* Update `is_literal_tuple/list` to use `is_base_container`
* Use `as_string` when giving out function or variable name for message.
* Fix broken baseContainer test
* Use safe_infer for inferencing `target_instance`
* Swap opreators message
* Address CR comments; no more try/catch for infer & Add more test cases
* Add more test cases and changed few cases to cover more cases.
* Remove `try/catch` from `safe_infer` since `safe_infer` will return
`None` when it encounters exceptions.
* Comparison from infer to be more explicit; using `None` instead of
relying on `bool`
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/checkers')
-rw-r--r-- | tests/checkers/unittest_utils.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/checkers/unittest_utils.py b/tests/checkers/unittest_utils.py index cb10d4fce..2902d0de5 100644 --- a/tests/checkers/unittest_utils.py +++ b/tests/checkers/unittest_utils.py @@ -467,14 +467,14 @@ def test_if_typing_guard() -> None: def test_is_empty_literal() -> None: list_node = astroid.extract_node("a = []") - assert utils.is_empty_list_literal(list_node.value) + assert utils.is_base_container(list_node.value) not_empty_list_node = astroid.extract_node("a = [1,2,3]") - assert not utils.is_empty_list_literal(not_empty_list_node.value) + assert not utils.is_base_container(not_empty_list_node.value) tuple_node = astroid.extract_node("a = ()") - assert utils.is_empty_tuple_literal(tuple_node.value) + assert utils.is_base_container(tuple_node.value) not_empty_tuple_node = astroid.extract_node("a = (1,2)") - assert not utils.is_empty_tuple_literal(not_empty_tuple_node.value) + assert not utils.is_base_container(not_empty_tuple_node.value) dict_node = astroid.extract_node("a = {}") assert utils.is_empty_dict_literal(dict_node.value) |