Skip to content

Commit f4320f1

Browse files
authored
build: treat warnings as errors (#262)
1 parent eb791ec commit f4320f1

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

packages/google-cloud-core/google/cloud/_helpers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
grpc = None
4040

4141

42-
_NOW = datetime.datetime.utcnow # To be replaced by tests.
42+
_NOW = datetime.datetime.now(datetime.timezone.utc)
4343
UTC = datetime.timezone.utc # Singleton instance to be used throughout.
4444
_EPOCH = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
4545

packages/google-cloud-core/noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def default(session):
7373
)
7474

7575
# Install all test dependencies, then install local packages in-place.
76-
session.install("pytest", "pytest-cov", "grpcio >= 1.0.2", "-c", constraints_path)
77-
session.install("-e", ".", "-c", constraints_path)
76+
session.install("pytest", "pytest-cov", "-c", constraints_path)
77+
session.install("-e", ".[grpc]", "-c", constraints_path)
7878

7979
# Run py.test against the unit tests.
8080
session.run(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[pytest]
2+
filterwarnings =
3+
# treat all warnings as errors
4+
error
5+
# Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed
6+
ignore:.*custom tp_new.*in Python 3.14:DeprecationWarning
7+
# Remove once Release PR https://github.com/googleapis/python-api-common-protos/pull/191 is merged
8+
ignore:.*pkg_resources.declare_namespace:DeprecationWarning
9+
ignore:.*pkg_resources is deprecated as an API:DeprecationWarning

packages/google-cloud-core/setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
"google-auth >= 1.25.0, < 3.0dev",
3333
"importlib-metadata > 1.0.0; python_version<'3.8'",
3434
]
35-
extras = {"grpc": "grpcio >= 1.38.0, < 2.0dev"}
36-
35+
extras = {
36+
"grpc": [
37+
"grpcio >= 1.38.0, < 2.0dev",
38+
"grpcio-status >= 1.38.0, < 2.0.dev0",
39+
],
40+
}
3741

3842
# Setup boilerplate below this line.
3943

packages/google-cloud-core/tests/unit/test__helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_w_utc_datetime(self):
138138
from google.cloud._helpers import UTC
139139
from google.cloud._helpers import _microseconds_from_datetime
140140

141-
NOW = datetime.datetime.utcnow().replace(tzinfo=UTC)
141+
NOW = datetime.datetime.now().replace(tzinfo=UTC)
142142
NOW_MICROS = _microseconds_from_datetime(NOW)
143143
MILLIS = NOW_MICROS // 1000
144144
result = self._call_fut(NOW)
@@ -163,7 +163,7 @@ def test_w_naive_datetime(self):
163163
from google.cloud._helpers import UTC
164164
from google.cloud._helpers import _microseconds_from_datetime
165165

166-
NOW = datetime.datetime.utcnow()
166+
NOW = datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
167167
UTC_NOW = NOW.replace(tzinfo=UTC)
168168
UTC_NOW_MICROS = _microseconds_from_datetime(UTC_NOW)
169169
MILLIS = UTC_NOW_MICROS // 1000

0 commit comments

Comments
 (0)