Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type hints for openlibrary/utils/sentry.py #6329

Merged
merged 1 commit into from
Mar 24, 2022
Merged
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
14 changes: 5 additions & 9 deletions openlibrary/utils/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from openlibrary.utils import get_software_version


def header_name_from_env(env_name):
# type: (str) -> str
def header_name_from_env(env_name: str) -> str:
"""
Convert an env name as stored in web.ctx.env to a "normal"
header name
Expand All @@ -24,8 +23,7 @@ def header_name_from_env(env_name):
return header_name.lower().replace('_', '-')


def add_web_ctx_to_event(event, hint):
# type: (dict, dict) -> dict
def add_web_ctx_to_event(event: dict, hint: dict) -> dict:
if not web.ctx:
return event

Expand All @@ -48,10 +46,9 @@ def add_web_ctx_to_event(event, hint):


class Sentry:
def __init__(self, config):
# type: (dict) -> None
def __init__(self, config: dict) -> None:
self.config = config
self.enabled = config.get('enabled') # type: bool
self.enabled: bool = config.get('enabled')
self.logger = logging.getLogger("sentry")
self.logger.info(f"Setting up sentry (enabled={self.enabled})")

Expand All @@ -62,8 +59,7 @@ def init(self):
release=get_software_version(),
)

def bind_to_webpy_app(self, app):
# type: (web.application) -> None
def bind_to_webpy_app(self, app: web.application) -> None:
_internalerror = app.internalerror

def capture_exception():
Expand Down