From 070a22c96f35ca8f57aa37a973907f20f4349d6d Mon Sep 17 00:00:00 2001 From: Leighton Date: Thu, 26 Sep 2019 14:30:12 -0700 Subject: [PATCH] fix lint --- .../src/opentelemetry/metrics/__init__.py | 16 +++++----- .../src/opentelemetry/sdk/metrics/__init__.py | 30 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/opentelemetry-api/src/opentelemetry/metrics/__init__.py b/opentelemetry-api/src/opentelemetry/metrics/__init__.py index 891d7a60d34..ce61efcfc68 100644 --- a/opentelemetry-api/src/opentelemetry/metrics/__init__.py +++ b/opentelemetry-api/src/opentelemetry/metrics/__init__.py @@ -32,7 +32,7 @@ from opentelemetry.util import loader -_ValueT = TypeVar("_ValueT", int, float) +ValueT = TypeVar("ValueT", int, float) class DefaultMetricHandle: @@ -43,17 +43,17 @@ class DefaultMetricHandle: class CounterHandle: - def add(self, value: _ValueT) -> None: + def add(self, value: ValueT) -> None: """Increases the value of the handle by ``value``""" class GaugeHandle: - def set(self, value: _ValueT) -> None: + def set(self, value: ValueT) -> None: """Sets the current value of the handle to ``value``.""" class MeasureHandle: - def record(self, value: _ValueT) -> None: + def record(self, value: ValueT) -> None: """Records the given ``value`` to this handle.""" @@ -124,7 +124,7 @@ def get_handle(self, label_values: Tuple[str, ...]) -> "MeasureHandle": return MeasureHandle() -_MetricT = TypeVar("_MetricT", Counter, Gauge, Measure) +Metric = TypeVar("Metric", Counter, Gauge, Measure) # pylint: disable=unused-argument @@ -139,7 +139,7 @@ class Meter: def record_batch( self, label_values: Tuple[str, ...], - record_tuples: Tuple[Tuple["Metric", _ValueT]], + record_tuples: Tuple[Tuple["Metric", ValueT]], ) -> None: """Atomically records a batch of `Metric` and value pairs. @@ -159,8 +159,8 @@ def create_metric( name: str, description: str, unit: str, - value_type: Type[_ValueT], - metric_type: Type[_MetricT], + value_type: Type[ValueT], + metric_type: Type[Metric], label_keys: Tuple[str, ...] = None, enabled: bool = True, monotonic: bool = False, diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py index a205d37e9be..690e1e121ed 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py @@ -23,7 +23,7 @@ class BaseHandle: def __init__( self, - value_type: Type[metrics_api._ValueT], + value_type: Type[metrics_api.ValueT], enabled: bool, monotonic: bool, ): @@ -32,7 +32,7 @@ def __init__( self.enabled = enabled self.monotonic = monotonic - def _validate_update(self, value: metrics_api._ValueT): + def _validate_update(self, value: metrics_api.ValueT): if not self.enabled: return False if self.monotonic and value < 0: @@ -47,32 +47,32 @@ def _validate_update(self, value: metrics_api._ValueT): class CounterHandle(metrics_api.CounterHandle, BaseHandle): - def update(self, value: metrics_api._ValueT) -> None: + def update(self, value: metrics_api.ValueT) -> None: if self._validate_update(value): self.data += value - def add(self, value: metrics_api._ValueT) -> None: + def add(self, value: metrics_api.ValueT) -> None: """See `opentelemetry.metrics.CounterHandle._add`.""" self.update(value) class GaugeHandle(metrics_api.GaugeHandle, BaseHandle): - def update(self, value: metrics_api._ValueT) -> None: + def update(self, value: metrics_api.ValueT) -> None: if self._validate_update(value): self.data = value - def set(self, value: metrics_api._ValueT) -> None: + def set(self, value: metrics_api.ValueT) -> None: """See `opentelemetry.metrics.GaugeHandle._set`.""" self.update(value) class MeasureHandle(metrics_api.MeasureHandle, BaseHandle): - def update(self, value: metrics_api._ValueT) -> None: + def update(self, value: metrics_api.ValueT) -> None: if self._validate_update(value): pass # TODO: record - def record(self, value: metrics_api._ValueT) -> None: + def record(self, value: metrics_api.ValueT) -> None: """See `opentelemetry.metrics.MeasureHandle._record`.""" self.update(value) @@ -87,7 +87,7 @@ def __init__( name: str, description: str, unit: str, - value_type: Type[metrics_api._ValueT], + value_type: Type[metrics_api.ValueT], label_keys: Tuple[str, ...] = None, enabled: bool = True, monotonic: bool = False, @@ -127,7 +127,7 @@ def __init__( name: str, description: str, unit: str, - value_type: Type[metrics_api._ValueT], + value_type: Type[metrics_api.ValueT], label_keys: Tuple[str, ...] = None, enabled: bool = True, monotonic: bool = True, @@ -157,7 +157,7 @@ def __init__( name: str, description: str, unit: str, - value_type: Type[metrics_api._ValueT], + value_type: Type[metrics_api.ValueT], label_keys: Tuple[str, ...] = None, enabled: bool = True, monotonic: bool = False, @@ -187,7 +187,7 @@ def __init__( name: str, description: str, unit: str, - value_type: Type[metrics_api._ValueT], + value_type: Type[metrics_api.ValueT], label_keys: Tuple[str, ...] = None, enabled: bool = False, monotonic: bool = False, @@ -209,7 +209,7 @@ class Meter(metrics_api.Meter): def record_batch( self, label_values: Tuple[str, ...], - record_tuples: Tuple[Tuple[metrics_api.Metric, metrics_api._ValueT]], + record_tuples: Tuple[Tuple[metrics_api.Metric, metrics_api.ValueT]], ) -> None: """See `opentelemetry.metrics.Meter.record_batch`.""" for metric, value in record_tuples: @@ -220,8 +220,8 @@ def create_metric( name: str, description: str, unit: str, - value_type: Type[metrics_api._ValueT], - metric_type: Type[metrics_api._MetricT], + value_type: Type[metrics_api.ValueT], + metric_type: Type[metrics_api.Metric], label_keys: Tuple[str, ...] = None, enabled: bool = True, monotonic: bool = False,