From acd6f5a8a19db709e835e2686b87d4db3dca254f Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Fri, 3 Jan 2025 15:22:02 -0500 Subject: [PATCH] Remove deprecation warnings (#1416) * tests/expressions/test_parser.py::test_is_null Deprecated in 0.8.0, will be removed in 0.9.0. Parsing expressions with table name is deprecated. Only provide field names in the row_filter. * tests/catalog/test_rest.py: Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI configuration --- pyiceberg/utils/deprecated.py | 1 - tests/catalog/test_rest.py | 33 ++++++++++++++++++++++++++++++++ tests/expressions/test_parser.py | 1 - 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/pyiceberg/utils/deprecated.py b/pyiceberg/utils/deprecated.py index da2cb3b500..b196f47ec6 100644 --- a/pyiceberg/utils/deprecated.py +++ b/pyiceberg/utils/deprecated.py @@ -56,7 +56,6 @@ def deprecation_message(deprecated_in: str, removed_in: str, help_message: Optio def _deprecation_warning(message: str) -> None: with warnings.catch_warnings(): # temporarily override warning handling - warnings.simplefilter("always", DeprecationWarning) # turn off filter warnings.warn( message, category=DeprecationWarning, diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index 091a67166b..2a4b3a7a1f 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -121,6 +121,9 @@ def test_no_uri_supplied() -> None: RestCatalog("production") +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_200(rest_mock: Mocker) -> None: rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -141,6 +144,9 @@ def test_token_200(rest_mock: Mocker) -> None: ) +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_200_without_optional_fields(rest_mock: Mocker) -> None: rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -157,6 +163,9 @@ def test_token_200_without_optional_fields(rest_mock: Mocker) -> None: ) +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_with_optional_oauth_params(rest_mock: Mocker) -> None: mock_request = rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -179,6 +188,9 @@ def test_token_with_optional_oauth_params(rest_mock: Mocker) -> None: assert TEST_RESOURCE in mock_request.last_request.text +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_with_optional_oauth_params_as_empty(rest_mock: Mocker) -> None: mock_request = rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -199,6 +211,9 @@ def test_token_with_optional_oauth_params_as_empty(rest_mock: Mocker) -> None: assert TEST_RESOURCE not in mock_request.last_request.text +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_with_default_scope(rest_mock: Mocker) -> None: mock_request = rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -217,6 +232,9 @@ def test_token_with_default_scope(rest_mock: Mocker) -> None: assert "catalog" in mock_request.last_request.text +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_with_custom_scope(rest_mock: Mocker) -> None: mock_request = rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -236,6 +254,9 @@ def test_token_with_custom_scope(rest_mock: Mocker) -> None: assert TEST_SCOPE in mock_request.last_request.text +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_200_w_auth_url(rest_mock: Mocker) -> None: rest_mock.post( TEST_AUTH_URL, @@ -258,6 +279,9 @@ def test_token_200_w_auth_url(rest_mock: Mocker) -> None: # pylint: enable=W0212 +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_config_200(requests_mock: Mocker) -> None: requests_mock.get( f"{TEST_URI}v1/config", @@ -343,6 +367,9 @@ def test_config_sets_headers(requests_mock: Mocker) -> None: ) +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_400(rest_mock: Mocker) -> None: rest_mock.post( f"{TEST_URI}v1/oauth/tokens", @@ -356,6 +383,9 @@ def test_token_400(rest_mock: Mocker) -> None: assert str(e.value) == "invalid_client: Credentials for key invalid_key do not match" +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_token_401(rest_mock: Mocker) -> None: message = "invalid_client" rest_mock.post( @@ -489,6 +519,9 @@ def test_list_namespace_with_parent_200(rest_mock: Mocker) -> None: ] +@pytest.mark.filterwarnings( + "ignore:Deprecated in 0.8.0, will be removed in 1.0.0. Iceberg REST client is missing the OAuth2 server URI:DeprecationWarning" +) def test_list_namespaces_token_expired(rest_mock: Mocker) -> None: new_token = "new_jwt_token" new_header = dict(TEST_HEADERS) diff --git a/tests/expressions/test_parser.py b/tests/expressions/test_parser.py index 085150edec..9d7a3ac094 100644 --- a/tests/expressions/test_parser.py +++ b/tests/expressions/test_parser.py @@ -70,7 +70,6 @@ def test_equals_false() -> None: def test_is_null() -> None: assert IsNull("foo") == parser.parse("foo is null") assert IsNull("foo") == parser.parse("foo IS NULL") - assert IsNull("foo") == parser.parse("table.foo IS NULL") def test_not_null() -> None: