Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: treat warnings as errors #1192

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[pytest]
filterwarnings =
# treat all warnings as errors
error
# Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed
ignore:.*custom tp_new.*in Python 3.14:DeprecationWarning
# Remove once Release PR https://github.com/googleapis/python-api-common-protos/pull/191 is merged
ignore:.*pkg_resources.declare_namespace:DeprecationWarning
ignore:.*pkg_resources is deprecated as an API:DeprecationWarning
# Remove once https://github.com/googleapis/python-storage/issues/1193 is fixed
ignore:.*unclosed:ResourceWarning
# Remove once release PR https://github.com/googleapis/proto-plus-python/pull/391 is merged
ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning:proto.datetime_helpers
# Remove once https://github.com/googleapis/python-crc32c/issues/178 is fixed
ignore:.*is using a pure python implementation:RuntimeWarning
# Remove once https://github.com/googleapis/python-storage/issues/1194 is fixed
ignore:datetime.datetime.utcnow\(\) is deprecated:DeprecationWarning
# Remove once https://github.com/dateutil/dateutil/issues/1314 is fixed
# dateutil is a dependency of pandas
ignore:datetime.datetime.utcfromtimestamp\(\) is deprecated:DeprecationWarning:dateutil.tz.tz
# Remove once https://github.com/googleapis/python-storage/issues/1195 is fixed
ignore:Blob.download_as_string\(\) is deprecated and will be removed in future. Use Blob.download_as_bytes\(\) instead:PendingDeprecationWarning
ignore:Assignment to.*is deprecated, as it is only valid before the bucket is created. Instead, pass the location to.*Bucket.create:DeprecationWarning
# Remove after support for Python 3.7 is dropped
ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning
11 changes: 8 additions & 3 deletions tests/system/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
import tempfile
import uuid
import warnings

import pytest
import mock
Expand Down Expand Up @@ -862,7 +861,10 @@ def test_blob_compose_w_generation_match_list(shared_bucket, blobs_to_delete):
to_append.upload_from_string(payload_to_append)
blobs_to_delete.append(to_append)

with warnings.catch_warnings(record=True) as log:
with pytest.warns(
DeprecationWarning,
match="'if_generation_match: type list' is deprecated and supported for backwards-compatability reasons only",
) as log:
with pytest.raises(exceptions.PreconditionFailed):
original.compose(
[original, to_append],
Expand All @@ -871,7 +873,10 @@ def test_blob_compose_w_generation_match_list(shared_bucket, blobs_to_delete):
)
assert len(log) == 2

with warnings.catch_warnings(record=True) as log:
with pytest.warns(
DeprecationWarning,
match="'if_generation_match: type list' is deprecated and supported for backwards-compatability reasons only",
) as log:
original.compose(
[original, to_append],
if_generation_match=[original.generation, to_append.generation],
Expand Down
52 changes: 36 additions & 16 deletions tests/system/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ def test_bucket_get_set_iam_policy(

def test_bucket_crud_w_requester_pays(storage_client, buckets_to_delete, user_project):
bucket_name = _helpers.unique_name("w-requester-pays")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name
assert created.requester_pays
Expand Down Expand Up @@ -248,10 +252,14 @@ def test_bucket_acls_iam_w_user_project(
storage_client, buckets_to_delete, user_project
):
bucket_name = _helpers.unique_name("acl-w-user-project")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name,
requester_pays=True,
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name,
requester_pays=True,
)
buckets_to_delete.append(created)

with_user_project = storage_client.bucket(bucket_name, user_project=user_project)
Expand Down Expand Up @@ -354,9 +362,13 @@ def test_bucket_copy_blob_w_user_project(
):
payload = b"DEADBEEF"
bucket_name = _helpers.unique_name("copy-w-requester-pays")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name
assert created.requester_pays
Expand Down Expand Up @@ -410,9 +422,13 @@ def test_bucket_copy_blob_w_metageneration_match(
):
payload = b"DEADBEEF"
bucket_name = _helpers.unique_name("generation-match")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated.",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name

Expand Down Expand Up @@ -442,9 +458,13 @@ def test_bucket_get_blob_with_user_project(
blob_name = "blob-name"
payload = b"DEADBEEF"
bucket_name = _helpers.unique_name("w-requester-pays")
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
with pytest.warns(
PendingDeprecationWarning,
match="requester_pays arg is deprecated. Use Bucket().requester_pays instead",
):
created = _helpers.retry_429_503(storage_client.create_bucket)(
bucket_name, requester_pays=True
)
buckets_to_delete.append(created)
assert created.name == bucket_name
assert created.requester_pays
Expand Down