zerver/webhooks: Change use of typing.Text to str.

This commit is contained in:
Aditya Bansal
2018-05-10 23:04:01 +05:30
committed by Tim Abbott
parent e8506b5020
commit 64ddfc6ac0
88 changed files with 277 additions and 319 deletions

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from typing import Text
from zerver.lib.test_classes import WebhookTestCase
class StatuspageHookTests(WebhookTestCase):
@@ -34,5 +33,5 @@ from **operational** to **under_maintenance**"
expected_message,
content_type="application/x-www-form-urlencoded")
def get_body(self, fixture_name: Text) -> Text:
def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("statuspage", fixture_name, file_type="json")

View File

@@ -5,33 +5,33 @@ from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import get_client, UserProfile
from django.http import HttpRequest, HttpResponse
from typing import Dict, Any, Text
from typing import Dict, Any
INCIDENT_TEMPLATE = u'**{name}** \n * State: **{state}** \n * Description: {content}'
COMPONENT_TEMPLATE = u'**{name}** has changed status from **{old_status}** to **{new_status}**'
TOPIC_TEMPLATE = u'{name}: {description}'
def get_incident_events_body(payload: Dict[Text, Any]) -> Text:
def get_incident_events_body(payload: Dict[str, Any]) -> str:
return INCIDENT_TEMPLATE.format(
name = payload["incident"]["name"],
state = payload["incident"]["status"],
content = payload["incident"]["incident_updates"][0]["body"],
)
def get_components_update_body(payload: Dict[Text, Any]) -> Text:
def get_components_update_body(payload: Dict[str, Any]) -> str:
return COMPONENT_TEMPLATE.format(
name = payload["component"]["name"],
old_status = payload["component_update"]["old_status"],
new_status = payload["component_update"]["new_status"],
)
def get_incident_topic(payload: Dict[Text, Any]) -> Text:
def get_incident_topic(payload: Dict[str, Any]) -> str:
return TOPIC_TEMPLATE.format(
name = payload["incident"]["name"],
description = payload["page"]["status_description"],
)
def get_component_topic(payload: Dict[Text, Any]) -> Text:
def get_component_topic(payload: Dict[str, Any]) -> str:
return TOPIC_TEMPLATE.format(
name = payload["component"]["name"],
description = payload["page"]["status_description"],