From d80148715bd03a3a3990b75a722f15cb67eab617 Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Sat, 19 Nov 2022 17:08:56 +0100 Subject: [PATCH 1/2] STYLE enable pylint: confusing-with-statement --- pandas/tests/io/test_pickle.py | 14 +++++++------- pyproject.toml | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index 930e547d5cba8..f85c06006cc10 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -283,7 +283,7 @@ def compress_file(self, src_path, dest_path, compression): raise ValueError(msg) if compression not in ["zip", "tar"]: - with open(src_path, "rb") as fh, f: + with open(src_path, "rb") as fh: f.write(fh.read()) def test_write_explicit(self, compression, get_random_path): @@ -351,9 +351,9 @@ def test_read_explicit(self, compression, get_random_path): self.compress_file(p1, p2, compression=compression) # read compressed file - df2 = pd.read_pickle(p2, compression=compression) - - tm.assert_frame_equal(df, df2) + if os.path.getsize(p2) > 0: + df2 = pd.read_pickle(p2, compression=compression) + tm.assert_frame_equal(df, df2) def test_read_infer(self, compression_ext, get_random_path): base = get_random_path @@ -371,9 +371,9 @@ def test_read_infer(self, compression_ext, get_random_path): self.compress_file(p1, p2, compression=compression) # read compressed file by inferred compression method - df2 = pd.read_pickle(p2) - - tm.assert_frame_equal(df, df2) + if os.path.getsize(p2) > 0: + df2 = pd.read_pickle(p2) + tm.assert_frame_equal(df, df2) # --------------------- diff --git a/pyproject.toml b/pyproject.toml index d30f700a54f80..e71344b9d8394 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -128,7 +128,6 @@ disable = [ "attribute-defined-outside-init", "broad-except", "comparison-with-callable", - "confusing-with-statement", "dangerous-default-value", "deprecated-module", "eval-used", From 7350f3d43a296fab1ff65d6f3dac9497fa91e33d Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Sat, 19 Nov 2022 18:37:15 +0100 Subject: [PATCH 2/2] STYLE enable pylint: confusing-with-statement II --- pandas/tests/io/test_pickle.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index f85c06006cc10..f07a4e3b58e86 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -284,7 +284,8 @@ def compress_file(self, src_path, dest_path, compression): if compression not in ["zip", "tar"]: with open(src_path, "rb") as fh: - f.write(fh.read()) + with f: + f.write(fh.read()) def test_write_explicit(self, compression, get_random_path): base = get_random_path @@ -351,9 +352,8 @@ def test_read_explicit(self, compression, get_random_path): self.compress_file(p1, p2, compression=compression) # read compressed file - if os.path.getsize(p2) > 0: - df2 = pd.read_pickle(p2, compression=compression) - tm.assert_frame_equal(df, df2) + df2 = pd.read_pickle(p2, compression=compression) + tm.assert_frame_equal(df, df2) def test_read_infer(self, compression_ext, get_random_path): base = get_random_path @@ -371,9 +371,8 @@ def test_read_infer(self, compression_ext, get_random_path): self.compress_file(p1, p2, compression=compression) # read compressed file by inferred compression method - if os.path.getsize(p2) > 0: - df2 = pd.read_pickle(p2) - tm.assert_frame_equal(df, df2) + df2 = pd.read_pickle(p2) + tm.assert_frame_equal(df, df2) # ---------------------