Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen committed Sep 26, 2019
1 parent cedcd1e commit 070a22c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions opentelemetry-api/src/opentelemetry/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from opentelemetry.util import loader

_ValueT = TypeVar("_ValueT", int, float)
ValueT = TypeVar("ValueT", int, float)


class DefaultMetricHandle:
Expand All @@ -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."""


Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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,
Expand Down
30 changes: 15 additions & 15 deletions opentelemetry-sdk/src/opentelemetry/sdk/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand All @@ -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:
Expand All @@ -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)

Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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,
Expand Down

0 comments on commit 070a22c

Please sign in to comment.