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

This commit is contained in:
Aditya Bansal
2018-05-11 05:13:34 +05:30
committed by Tim Abbott
parent d18b193b5b
commit a40ae4cae5
7 changed files with 96 additions and 96 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
from typing import Any, Dict, Iterable, Optional, Text
from typing import Any, Dict, Iterable, Optional
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
@@ -15,7 +15,7 @@ from zerver.lib.webhooks.git import SUBJECT_WITH_BRANCH_TEMPLATE, \
get_pull_request_event_message, get_push_commits_event_message
from zerver.models import UserProfile
def format_push_event(payload: Dict[str, Any]) -> Text:
def format_push_event(payload: Dict[str, Any]) -> str:
for commit in payload['commits']:
commit['sha'] = commit['id']
@@ -31,7 +31,7 @@ def format_push_event(payload: Dict[str, Any]) -> Text:
return get_push_commits_event_message(**data)
def format_new_branch_event(payload: Dict[str, Any]) -> Text:
def format_new_branch_event(payload: Dict[str, Any]) -> str:
branch_name = payload['ref']
url = '{}/src/{}'.format(payload['repository']['html_url'], branch_name)
@@ -43,7 +43,7 @@ def format_new_branch_event(payload: Dict[str, Any]) -> Text:
}
return get_create_branch_event_message(**data)
def format_pull_request_event(payload: Dict[str, Any]) -> Text:
def format_pull_request_event(payload: Dict[str, Any]) -> str:
data = {
'user_name': payload['pull_request']['user']['username'],
@@ -64,7 +64,7 @@ def format_pull_request_event(payload: Dict[str, Any]) -> Text:
@has_request_variables
def api_gogs_webhook(request: HttpRequest, user_profile: UserProfile,
payload: Dict[str, Any]=REQ(argument_type='body'),
branches: Optional[Text]=REQ(default=None)) -> HttpResponse:
branches: Optional[str]=REQ(default=None)) -> HttpResponse:
repo = payload['repository']['name']
event = validate_extract_webhook_http_header(request, 'X_GOGS_EVENT', 'Gogs')