From 0f71997448209dc55e66390d71e0dc83fb9d224b Mon Sep 17 00:00:00 2001 From: H L Date: Mon, 21 Nov 2022 21:51:16 -0800 Subject: [PATCH] fixed pylint use-impilcit-booleaness-not-comparison warnings in code --- pandas/_testing/asserters.py | 4 ++-- pandas/io/sas/sas7bdat.py | 4 +--- pandas/io/xml.py | 2 +- pandas/tests/apply/test_frame_apply.py | 2 +- pandas/tests/frame/test_api.py | 2 +- pandas/tests/io/pytables/test_store.py | 2 +- pandas/tests/io/test_stata.py | 2 +- pandas/tests/series/test_api.py | 2 +- pyproject.toml | 1 - 9 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pandas/_testing/asserters.py b/pandas/_testing/asserters.py index a5641465b0be0..a79f7700ce75f 100644 --- a/pandas/_testing/asserters.py +++ b/pandas/_testing/asserters.py @@ -1236,10 +1236,10 @@ def assert_equal(left, right, **kwargs) -> None: elif isinstance(left, np.ndarray): assert_numpy_array_equal(left, right, **kwargs) elif isinstance(left, str): - assert kwargs == {} + assert not kwargs assert left == right else: - assert kwargs == {} + assert not kwargs assert_almost_equal(left, right) diff --git a/pandas/io/sas/sas7bdat.py b/pandas/io/sas/sas7bdat.py index fd47396347ff9..175e1327ec654 100644 --- a/pandas/io/sas/sas7bdat.py +++ b/pandas/io/sas/sas7bdat.py @@ -384,9 +384,7 @@ def _process_page_meta(self) -> bool: is_data_page = self._current_page_type == const.page_data_type is_mix_page = self._current_page_type == const.page_mix_type return bool( - is_data_page - or is_mix_page - or self._current_page_data_subheader_pointers != [] + is_data_page or is_mix_page or self._current_page_data_subheader_pointers ) def _read_page_header(self) -> None: diff --git a/pandas/io/xml.py b/pandas/io/xml.py index b5973257b8ee2..2cb1cc781dfa7 100644 --- a/pandas/io/xml.py +++ b/pandas/io/xml.py @@ -373,7 +373,7 @@ def _iterparse_nodes(self, iterparse: Callable) -> list[dict[str, str | None]]: ): del elem.getparent()[0] - if dicts == []: + if not dicts: raise ParserError("No result from selected items in iterparse.") keys = list(dict.fromkeys([k for d in dicts for k in d.keys()])) diff --git a/pandas/tests/apply/test_frame_apply.py b/pandas/tests/apply/test_frame_apply.py index 28c776d0a6d35..aba9ee507e86e 100644 --- a/pandas/tests/apply/test_frame_apply.py +++ b/pandas/tests/apply/test_frame_apply.py @@ -125,7 +125,7 @@ def test_apply_with_reduce_empty(): tm.assert_series_equal(result, expected) # Ensure that x.append hasn't been called - assert x == [] + assert not x @pytest.mark.parametrize("func", ["sum", "prod", "any", "all"]) diff --git a/pandas/tests/frame/test_api.py b/pandas/tests/frame/test_api.py index 1ab20c282b23a..abe8ab06212f2 100644 --- a/pandas/tests/frame/test_api.py +++ b/pandas/tests/frame/test_api.py @@ -315,7 +315,7 @@ async def test_tab_complete_warning(self, ip, frame_or_series): def test_attrs(self): df = DataFrame({"A": [2, 3]}) - assert df.attrs == {} + assert not df.attrs df.attrs["version"] = 1 result = df.rename(columns=str) diff --git a/pandas/tests/io/pytables/test_store.py b/pandas/tests/io/pytables/test_store.py index 22873b0096817..a105bcdee4cdc 100644 --- a/pandas/tests/io/pytables/test_store.py +++ b/pandas/tests/io/pytables/test_store.py @@ -104,7 +104,7 @@ def test_iter_empty(setup_path): with ensure_clean_store(setup_path) as store: # GH 12221 - assert list(store) == [] + assert not list(store) def test_repr(setup_path): diff --git a/pandas/tests/io/test_stata.py b/pandas/tests/io/test_stata.py index 32b616cd9ab9b..6a31d89d3f874 100644 --- a/pandas/tests/io/test_stata.py +++ b/pandas/tests/io/test_stata.py @@ -614,7 +614,7 @@ def test_value_labels_old_format(self, datapath): # predates supporting value labels. dpath = datapath("io", "data", "stata", "S4_EDUC1.dta") with StataReader(dpath) as reader: - assert reader.value_labels() == {} + assert not reader.value_labels() def test_date_export_formats(self): columns = ["tc", "td", "tw", "tm", "tq", "th", "ty"] diff --git a/pandas/tests/series/test_api.py b/pandas/tests/series/test_api.py index 4852788ef2c06..cd9b9c21097c4 100644 --- a/pandas/tests/series/test_api.py +++ b/pandas/tests/series/test_api.py @@ -162,7 +162,7 @@ def test_integer_series_size(self, dtype): def test_attrs(self): s = Series([0, 1], name="abc") - assert s.attrs == {} + assert not s.attrs s.attrs["version"] = 1 result = s + 1 assert result.attrs == {"version": 1} diff --git a/pyproject.toml b/pyproject.toml index 672a3208ac5ab..7475de3a5bcad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,6 @@ disable = [ "unidiomatic-typecheck", "unnecessary-dunder-call", "unnecessary-lambda-assignment", - "use-implicit-booleaness-not-comparison", "use-implicit-booleaness-not-len", "wrong-import-order", "wrong-import-position",