Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions baseplate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import os
import sys

from typing import TYPE_CHECKING

from baseplate import config, metrics
from baseplate.core import Baseplate
from baseplate.diagnostics import tracing
from baseplate._utils import warn_deprecated


def metrics_client_from_config(raw_config):
if TYPE_CHECKING:
import raven


def metrics_client_from_config(raw_config: config.RawConfig) -> metrics.Client:
"""Configure and return a metrics client.

This expects two configuration options:
Expand All @@ -33,15 +39,17 @@ def metrics_client_from_config(raw_config):
return metrics.make_client(cfg.metrics.namespace, cfg.metrics.endpoint)


def make_metrics_client(raw_config):
def make_metrics_client(raw_config: config.RawConfig) -> metrics.Client:
warn_deprecated(
"make_metrics_client is deprecated in favor of the more "
"consistently named metrics_client_from_config"
)
return metrics_client_from_config(raw_config)


def tracing_client_from_config(raw_config, log_if_unconfigured=True):
def tracing_client_from_config(
raw_config: config.RawConfig, log_if_unconfigured: bool = True
) -> tracing.TracingClient:
"""Configure and return a tracing client.

This expects one configuration option and can take many optional ones:
Expand Down Expand Up @@ -105,15 +113,17 @@ def tracing_client_from_config(raw_config, log_if_unconfigured=True):
)


def make_tracing_client(raw_config, log_if_unconfigured=True):
def make_tracing_client(
raw_config: config.RawConfig, log_if_unconfigured: bool = True
) -> tracing.TracingClient:
warn_deprecated(
"make_tracing_client is deprecated in favor of the more "
"consistently named tracing_client_from_config"
)
return tracing_client_from_config(raw_config, log_if_unconfigured)


def error_reporter_from_config(raw_config, module_name):
def error_reporter_from_config(raw_config: config.RawConfig, module_name: str) -> "raven.Client":
"""Configure and return a error reporter.

This expects one configuration option and can take many optional ones:
Expand Down Expand Up @@ -149,7 +159,7 @@ def error_reporter_from_config(raw_config, module_name):
:rtype: :py:class:`raven.Client`

"""
import raven
import raven # pylint: disable=redefined-outer-name

cfg = config.parse_config(
raw_config,
Expand Down
2 changes: 1 addition & 1 deletion baseplate/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import warnings


def warn_deprecated(message):
def warn_deprecated(message: str) -> None:
"""Emit a deprecation warning from the caller.

The stacktrace for the warning will point to the place where the function
Expand Down
Loading