From 4e953f6ddc1aca886778bdcf9b3049f8a29b47d8 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Thu, 19 May 2022 14:35:14 +0200 Subject: [PATCH] Python: Ensure all `test_get_value` methods return optional value --- glean-core/python/glean/metrics/event.py | 2 +- glean-core/python/glean/metrics/string.py | 2 +- glean-core/python/glean/metrics/timespan.py | 2 +- glean-core/python/glean/metrics/timing_distribution.py | 4 +++- glean-core/python/glean/metrics/url.py | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/glean-core/python/glean/metrics/event.py b/glean-core/python/glean/metrics/event.py index faa5c7601..7839144b0 100644 --- a/glean-core/python/glean/metrics/event.py +++ b/glean-core/python/glean/metrics/event.py @@ -74,7 +74,7 @@ class EventMetricType: self._inner.record(extra) - def test_get_value(self, ping_name: Optional[str] = None) -> List[RecordedEvent]: + def test_get_value(self, ping_name: Optional[str] = None) -> Optional[List[RecordedEvent]]: """ Returns the stored value for testing purposes only. diff --git a/glean-core/python/glean/metrics/string.py b/glean-core/python/glean/metrics/string.py index 67dafe58f..a8bb30d69 100644 --- a/glean-core/python/glean/metrics/string.py +++ b/glean-core/python/glean/metrics/string.py @@ -40,7 +40,7 @@ class StringMetricType: self._inner.set(value) - def test_get_value(self, ping_name: Optional[str] = None) -> str: + def test_get_value(self, ping_name: Optional[str] = None) -> Optional[str]: return self._inner.test_get_value(ping_name) def test_get_num_recorded_errors( diff --git a/glean-core/python/glean/metrics/timespan.py b/glean-core/python/glean/metrics/timespan.py index 730bfbb30..712b80e4d 100644 --- a/glean-core/python/glean/metrics/timespan.py +++ b/glean-core/python/glean/metrics/timespan.py @@ -103,7 +103,7 @@ class TimespanMetricType: """ self._inner.set_raw_nanos(elapsed_nanos) - def test_get_value(self, ping_name: Optional[str] = None) -> int: + def test_get_value(self, ping_name: Optional[str] = None) -> Optional[int]: """ Returns the stored value for testing purposes only. diff --git a/glean-core/python/glean/metrics/timing_distribution.py b/glean-core/python/glean/metrics/timing_distribution.py index 4529cef8c..978953219 100644 --- a/glean-core/python/glean/metrics/timing_distribution.py +++ b/glean-core/python/glean/metrics/timing_distribution.py @@ -96,7 +96,9 @@ class TimingDistributionMetricType: """ return self._TimingDistributionContextManager(self) - def test_get_value(self, ping_name: Optional[str] = None) -> DistributionData: + def test_get_value( + self, ping_name: Optional[str] = None + ) -> Optional[DistributionData]: """ Returns the stored value for testing purposes only. diff --git a/glean-core/python/glean/metrics/url.py b/glean-core/python/glean/metrics/url.py index dac5e8132..03f85e704 100644 --- a/glean-core/python/glean/metrics/url.py +++ b/glean-core/python/glean/metrics/url.py @@ -41,7 +41,7 @@ class UrlMetricType: self._inner.set(value) - def test_get_value(self, ping_name: Optional[str] = None) -> str: + def test_get_value(self, ping_name: Optional[str] = None) -> Optional[str]: return self._inner.test_get_value(ping_name) def test_get_num_recorded_errors(