diff --git a/python/pyarrow/pandas_compat.py b/python/pyarrow/pandas_compat.py index bb54c3b22c3..a85146a6b78 100644 --- a/python/pyarrow/pandas_compat.py +++ b/python/pyarrow/pandas_compat.py @@ -33,7 +33,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa from pyarrow.lib import _pandas_api, frombytes, is_threading_enabled # noqa diff --git a/python/pyarrow/tests/interchange/test_conversion.py b/python/pyarrow/tests/interchange/test_conversion.py index 50da6693aff..a584f379738 100644 --- a/python/pyarrow/tests/interchange/test_conversion.py +++ b/python/pyarrow/tests/interchange/test_conversion.py @@ -23,7 +23,7 @@ try: import numpy as np except ImportError: - np = None + pass import pyarrow.interchange as pi from pyarrow.interchange.column import ( diff --git a/python/pyarrow/tests/interchange/test_interchange_spec.py b/python/pyarrow/tests/interchange/test_interchange_spec.py index cea694d1c1e..56a424fd57a 100644 --- a/python/pyarrow/tests/interchange/test_interchange_spec.py +++ b/python/pyarrow/tests/interchange/test_interchange_spec.py @@ -20,10 +20,11 @@ import hypothesis.strategies as st import pytest +np = None try: import numpy as np except ImportError: - np = None + pass import pyarrow as pa import pyarrow.tests.strategies as past diff --git a/python/pyarrow/tests/parquet/common.py b/python/pyarrow/tests/parquet/common.py index 4f5946649b8..7351a4c3e94 100644 --- a/python/pyarrow/tests/parquet/common.py +++ b/python/pyarrow/tests/parquet/common.py @@ -20,7 +20,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa from pyarrow.tests import util diff --git a/python/pyarrow/tests/parquet/test_basic.py b/python/pyarrow/tests/parquet/test_basic.py index 67515c5e247..c6fe2942e1f 100644 --- a/python/pyarrow/tests/parquet/test_basic.py +++ b/python/pyarrow/tests/parquet/test_basic.py @@ -44,12 +44,12 @@ from pyarrow.tests.pandas_examples import dataframe_with_lists from pyarrow.tests.parquet.common import alltypes_sample except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] # Marks all of the tests in this module # Ignore these with pytest ... -m 'not parquet' diff --git a/python/pyarrow/tests/parquet/test_compliant_nested_type.py b/python/pyarrow/tests/parquet/test_compliant_nested_type.py index 2345855a332..8a64cd0cab7 100644 --- a/python/pyarrow/tests/parquet/test_compliant_nested_type.py +++ b/python/pyarrow/tests/parquet/test_compliant_nested_type.py @@ -32,7 +32,7 @@ from pyarrow.tests.parquet.common import _roundtrip_pandas_dataframe except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_data_types.py b/python/pyarrow/tests/parquet/test_data_types.py index c546bc1532a..66e12d11b21 100644 --- a/python/pyarrow/tests/parquet/test_data_types.py +++ b/python/pyarrow/tests/parquet/test_data_types.py @@ -22,7 +22,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa @@ -44,7 +44,7 @@ dataframe_with_lists) from pyarrow.tests.parquet.common import alltypes_sample except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_dataset.py b/python/pyarrow/tests/parquet/test_dataset.py index b8939443c1d..a162006dc0c 100644 --- a/python/pyarrow/tests/parquet/test_dataset.py +++ b/python/pyarrow/tests/parquet/test_dataset.py @@ -24,7 +24,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import unittest.mock as mock @@ -48,7 +48,7 @@ import pandas.testing as tm except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_datetime.py b/python/pyarrow/tests/parquet/test_datetime.py index b89fd97cb91..62904937eb5 100644 --- a/python/pyarrow/tests/parquet/test_datetime.py +++ b/python/pyarrow/tests/parquet/test_datetime.py @@ -22,7 +22,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa @@ -41,7 +41,7 @@ from pyarrow.tests.parquet.common import _roundtrip_pandas_dataframe except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_metadata.py b/python/pyarrow/tests/parquet/test_metadata.py index 148bfebaa67..d8fafde185f 100644 --- a/python/pyarrow/tests/parquet/test_metadata.py +++ b/python/pyarrow/tests/parquet/test_metadata.py @@ -23,7 +23,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa @@ -44,7 +44,7 @@ from pyarrow.tests.parquet.common import alltypes_sample except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_pandas.py b/python/pyarrow/tests/parquet/test_pandas.py index 703232b7cac..3bb4842decb 100644 --- a/python/pyarrow/tests/parquet/test_pandas.py +++ b/python/pyarrow/tests/parquet/test_pandas.py @@ -21,7 +21,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa @@ -44,7 +44,7 @@ from pyarrow.tests.parquet.common import (_roundtrip_pandas_dataframe, alltypes_sample) except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_parquet_file.py b/python/pyarrow/tests/parquet/test_parquet_file.py index 24ffe612ef7..10a2b7e1de7 100644 --- a/python/pyarrow/tests/parquet/test_parquet_file.py +++ b/python/pyarrow/tests/parquet/test_parquet_file.py @@ -38,7 +38,7 @@ from pyarrow.tests.parquet.common import alltypes_sample except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/parquet/test_parquet_writer.py b/python/pyarrow/tests/parquet/test_parquet_writer.py index d1e9e874ba1..8f163dfc0b5 100644 --- a/python/pyarrow/tests/parquet/test_parquet_writer.py +++ b/python/pyarrow/tests/parquet/test_parquet_writer.py @@ -33,7 +33,7 @@ import pandas.testing as tm except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] # Marks all of the tests in this module diff --git a/python/pyarrow/tests/strategies.py b/python/pyarrow/tests/strategies.py index 450cce74f1d..243815c59f7 100644 --- a/python/pyarrow/tests/strategies.py +++ b/python/pyarrow/tests/strategies.py @@ -24,15 +24,15 @@ try: import hypothesis.extra.numpy as npst except ImportError: - npst = None + npst = None # type: ignore[assignment] try: import hypothesis.extra.pytz as tzst except ImportError: - tzst = None + tzst = None # type: ignore[assignment] try: import zoneinfo except ImportError: - zoneinfo = None + zoneinfo = None # type: ignore[assignment] if sys.platform == 'win32': try: import tzdata # noqa:F401 @@ -41,7 +41,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa diff --git a/python/pyarrow/tests/test_adhoc_memory_leak.py b/python/pyarrow/tests/test_adhoc_memory_leak.py index 76a766984da..9f61bc7ddfe 100644 --- a/python/pyarrow/tests/test_adhoc_memory_leak.py +++ b/python/pyarrow/tests/test_adhoc_memory_leak.py @@ -20,7 +20,7 @@ try: import numpy as np except ImportError: - np = None + pass import pyarrow as pa import pyarrow.tests.util as test_util diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py index 009ab1e849b..ea9085025ec 100644 --- a/python/pyarrow/tests/test_array.py +++ b/python/pyarrow/tests/test_array.py @@ -30,7 +30,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa import pyarrow.tests.strategies as past diff --git a/python/pyarrow/tests/test_cffi.py b/python/pyarrow/tests/test_cffi.py index 84290a6b880..2d0ff8b45f1 100644 --- a/python/pyarrow/tests/test_cffi.py +++ b/python/pyarrow/tests/test_cffi.py @@ -24,7 +24,7 @@ try: from pyarrow.cffi import ffi except ImportError: - ffi = None + ffi = None # type: ignore[assignment] import pytest @@ -32,7 +32,7 @@ import pandas as pd import pandas.testing as tm except ImportError: - pd = tm = None + pd = tm = None # type: ignore[assignment] needs_cffi = pytest.mark.skipif(ffi is None, diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index ad61dbc48a7..b2fdf7239f6 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -31,12 +31,12 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] try: import pandas as pd except ImportError: - pd = None + pd = None # type: ignore[assignment] import pyarrow as pa import pyarrow.compute as pc diff --git a/python/pyarrow/tests/test_convert_builtin.py b/python/pyarrow/tests/test_convert_builtin.py index 07286125c4c..468bddf58cb 100644 --- a/python/pyarrow/tests/test_convert_builtin.py +++ b/python/pyarrow/tests/test_convert_builtin.py @@ -27,7 +27,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] from pyarrow.pandas_compat import _pandas_api # noqa import pyarrow as pa diff --git a/python/pyarrow/tests/test_dataset.py b/python/pyarrow/tests/test_dataset.py index e7365643b84..d1cd3f6b8a1 100644 --- a/python/pyarrow/tests/test_dataset.py +++ b/python/pyarrow/tests/test_dataset.py @@ -32,7 +32,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa @@ -49,7 +49,7 @@ try: import pandas as pd except ImportError: - pd = None + pd = None # type: ignore[assignment] try: import pyarrow.dataset as ds diff --git a/python/pyarrow/tests/test_extension_type.py b/python/pyarrow/tests/test_extension_type.py index ebac37e862b..55b3775339e 100644 --- a/python/pyarrow/tests/test_extension_type.py +++ b/python/pyarrow/tests/test_extension_type.py @@ -27,7 +27,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa from pyarrow.vendored.version import Version diff --git a/python/pyarrow/tests/test_feather.py b/python/pyarrow/tests/test_feather.py index 054bf920b26..60efd496e7d 100644 --- a/python/pyarrow/tests/test_feather.py +++ b/python/pyarrow/tests/test_feather.py @@ -26,7 +26,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa import pyarrow.tests.strategies as past diff --git a/python/pyarrow/tests/test_flight.py b/python/pyarrow/tests/test_flight.py index 7f89c115324..39fcb7af9c3 100644 --- a/python/pyarrow/tests/test_flight.py +++ b/python/pyarrow/tests/test_flight.py @@ -32,7 +32,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa diff --git a/python/pyarrow/tests/test_io.py b/python/pyarrow/tests/test_io.py index a6d3546e57c..b1ec7674f87 100644 --- a/python/pyarrow/tests/test_io.py +++ b/python/pyarrow/tests/test_io.py @@ -33,7 +33,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] from pyarrow.util import guid from pyarrow import Codec diff --git a/python/pyarrow/tests/test_ipc.py b/python/pyarrow/tests/test_ipc.py index b3b3367223d..26df224ee49 100644 --- a/python/pyarrow/tests/test_ipc.py +++ b/python/pyarrow/tests/test_ipc.py @@ -28,7 +28,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa from pyarrow.tests.util import changed_environ, invoke_script diff --git a/python/pyarrow/tests/test_json.py b/python/pyarrow/tests/test_json.py index c3f9fe333bd..dffaa6f8ad3 100644 --- a/python/pyarrow/tests/test_json.py +++ b/python/pyarrow/tests/test_json.py @@ -27,7 +27,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index ceea2527da0..6ceeeded646 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -38,7 +38,7 @@ VisibleDeprecationWarning as _np_VisibleDeprecationWarning ) except ImportError: - np = None + np = None # type: ignore[assignment] from pyarrow.pandas_compat import get_logical_type, _pandas_api from pyarrow.tests.util import invoke_script, random_ascii, rands diff --git a/python/pyarrow/tests/test_scalars.py b/python/pyarrow/tests/test_scalars.py index 0f62dd98f82..f48761b1918 100644 --- a/python/pyarrow/tests/test_scalars.py +++ b/python/pyarrow/tests/test_scalars.py @@ -24,7 +24,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa import pyarrow.compute as pc diff --git a/python/pyarrow/tests/test_schema.py b/python/pyarrow/tests/test_schema.py index a1197ed2d08..6d1ff431819 100644 --- a/python/pyarrow/tests/test_schema.py +++ b/python/pyarrow/tests/test_schema.py @@ -23,7 +23,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa import pyarrow.tests.util as test_util diff --git a/python/pyarrow/tests/test_sparse_tensor.py b/python/pyarrow/tests/test_sparse_tensor.py index eca8090d77a..27974b80f80 100644 --- a/python/pyarrow/tests/test_sparse_tensor.py +++ b/python/pyarrow/tests/test_sparse_tensor.py @@ -26,12 +26,10 @@ import pyarrow as pa try: + import scipy from scipy.sparse import csr_array, coo_array, csr_matrix, coo_matrix except ImportError: - coo_matrix = None - csr_matrix = None - csr_array = None - coo_array = None + scipy = None # type: ignore[assignment] try: import sparse @@ -401,7 +399,7 @@ def test_dense_to_sparse_tensor(dtype_str, arrow_type, sparse_tensor_type): assert np.array_equal(array, result_array) -@pytest.mark.skipif(not coo_matrix, reason="requires scipy") +@pytest.mark.skipif(not scipy, reason="requires scipy") @pytest.mark.parametrize('sparse_object', (coo_array, coo_matrix)) @pytest.mark.parametrize('dtype_str,arrow_type', scipy_type_pairs) def test_sparse_coo_tensor_scipy_roundtrip(dtype_str, arrow_type, @@ -443,7 +441,7 @@ def test_sparse_coo_tensor_scipy_roundtrip(dtype_str, arrow_type, assert out_scipy_matrix.has_canonical_format -@pytest.mark.skipif(not csr_matrix, reason="requires scipy") +@pytest.mark.skipif(not scipy, reason="requires scipy") @pytest.mark.parametrize('sparse_object', (csr_array, csr_matrix)) @pytest.mark.parametrize('dtype_str,arrow_type', scipy_type_pairs) def test_sparse_csr_matrix_scipy_roundtrip(dtype_str, arrow_type, diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py index b65fb7d952c..ead5cbaddc5 100644 --- a/python/pyarrow/tests/test_table.py +++ b/python/pyarrow/tests/test_table.py @@ -23,7 +23,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pytest import pyarrow as pa import pyarrow.compute as pc diff --git a/python/pyarrow/tests/test_types.py b/python/pyarrow/tests/test_types.py index 60a713eb717..80193a69eb1 100644 --- a/python/pyarrow/tests/test_types.py +++ b/python/pyarrow/tests/test_types.py @@ -27,13 +27,13 @@ try: import hypothesis.extra.pytz as tzst except ImportError: - tzst = None + tzst = None # type: ignore[assignment] import weakref try: import numpy as np except ImportError: - np = None + pass import pyarrow as pa import pyarrow.types as types import pyarrow.tests.strategies as past @@ -1322,6 +1322,7 @@ def test_field_modified_copies(): assert f0.equals(f0_) +@pytest.mark.numpy def test_is_integer_value(): assert pa.types.is_integer_value(1) if np is not None: diff --git a/python/pyarrow/tests/test_udf.py b/python/pyarrow/tests/test_udf.py index 93004a30618..dbc30867971 100644 --- a/python/pyarrow/tests/test_udf.py +++ b/python/pyarrow/tests/test_udf.py @@ -21,7 +21,7 @@ try: import numpy as np except ImportError: - np = None + np = None # type: ignore[assignment] import pyarrow as pa from pyarrow import compute as pc