Skip to content

Commit

Permalink
improve typing
Browse files Browse the repository at this point in the history
  • Loading branch information
aamalev committed Jan 30, 2021
1 parent 6cd6bcd commit 75ee1bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions aioworkers_prometheus/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class Metric(LoggingEntity):
def set_config(self, config: ValueExtractor) -> None:
cfg = config.new_parent(logger=__package__)
super().set_config(cfg)
registry = self.config.get('registry', REGISTRY)
namespace = self.config.get('namespace')
registry: str = self.config.get('registry', REGISTRY)
namespace: Optional[str] = self.config.get('namespace')
cfg_metrics = self.config.get('metrics', {})
for attr, params in cfg_metrics.items():
kw = dict(params)
m_name = kw.setdefault('name', attr)
m_name: str = kw.setdefault('name', attr)
kw.setdefault('documentation', '')
m_type = kw.pop('type', 'gauge')
m_type: str = kw.pop('type', 'gauge')
cls = self.METRICS[m_type]
m_registry = kw.get('registry', registry)
m_registry: str = kw.get('registry', registry)
kw['registry'] = get_registry(m_registry)
m_namespace = kw.setdefault('namespace', namespace)
m_namespace: Optional[str] = kw.setdefault('namespace', namespace)
cache_key: Tuple = (m_registry, m_namespace, m_name, m_type)
cache_key += tuple(kw.get('labelnames', ()))
metric: Optional[metrics.MetricWrapperBase] = self._cache.get(cache_key)
Expand Down

0 comments on commit 75ee1bb

Please sign in to comment.