You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/28 13:35:39 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #14729: ARROW-18399: [Python] Reduce warnings during tests

pitrou commented on code in PR #14729:
URL: https://github.com/apache/arrow/pull/14729#discussion_r1031593419


##########
python/pyarrow/tests/parquet/test_basic.py:
##########
@@ -617,15 +618,15 @@ def test_read_non_existent_file(tempdir, use_legacy_dataset):
 
 @parametrize_legacy_dataset
 def test_read_table_doesnt_warn(datadir, use_legacy_dataset):
-    with pytest.warns(None) as record:
-        pq.read_table(datadir / 'v0.7.1.parquet',
-                      use_legacy_dataset=use_legacy_dataset)
-
     if use_legacy_dataset:
-        # FutureWarning: 'use_legacy_dataset=True'
-        assert len(record) == 1
+        with pytest.warns(FutureWarning):

Review Comment:
   Is it possible to match some relevant part of the warning message?



##########
python/pyarrow/conftest.py:
##########
@@ -265,3 +267,19 @@ def add_fs(doctest_namespace, request, tmp_path):
         doctest_namespace["local_path"] = str(tmp_path)
         doctest_namespace["path"] = str(path)
     yield
+
+
+@pytest.fixture(autouse=True)
+def _close_socket(monkeypatch):
+    """
+    There are occasions when a PytestUnraisableExceptionWarning is
+    raised from pyx files or other __del__ impls that doesn't properly
+    call the initial caller's .close when creating sockets. Here we'll
+    ensure sockets are closed.
+    """
+    class socket_(socket.socket):
+        def __del__(self):
+            if not self._closed:
+                self.close()

Review Comment:
   We definitely don't want to monkeypatch a core type just to avoid some warnings.
   
   If some of our routines fail to close a socket we should try to improve them. Otherwise we should just live with the warnings.



##########
python/pyarrow/tests/test_pandas.py:
##########
@@ -2164,9 +2172,17 @@ def test_nested_large_list(self):
         s = (pa.array([[[1, 2, 3], [4]], None],
                       type=pa.large_list(pa.large_list(pa.int64())))
              .to_pandas())
-        tm.assert_series_equal(
-            s, pd.Series([[[1, 2, 3], [4]], None], dtype=object),
-            check_names=False)
+
+        # pandas.testing generates a
+        # DeprecationWarning: elementwise comparison failed
+        # numpy.VisibleDeprecationWarning: Creating an ndarray
+        #     from ragged nested sequences ...

Review Comment:
   Since these are flagging behavior that is likely to change in the future, shouldn't we fix the underlying issues instead of simply silencing the warnings?



##########
python/pyarrow/parquet/core.py:
##########
@@ -1165,8 +1165,10 @@ def get_metadata(self):
         -------
         metadata : FileMetaData
         """
-        with self.open() as parquet:
-            return parquet.metadata
+        parquet = self.open()
+        meta = parquet.metadata
+        parquet.close(True)

Review Comment:
   Hmm, isn't it a bug if a `with` statement fails to close the file it just opened?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org