diff --git a/zerver/webhooks/airbrake/view.py b/zerver/webhooks/airbrake/view.py index cf2ebe0d5b..05ce3cfc51 100644 --- a/zerver/webhooks/airbrake/view.py +++ b/zerver/webhooks/airbrake/view.py @@ -2,12 +2,11 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.models import UserProfile AIRBRAKE_TOPIC_TEMPLATE = '{project_name}' diff --git a/zerver/webhooks/ansibletower/view.py b/zerver/webhooks/ansibletower/view.py index 9b5f78f83c..7c66cab0d9 100644 --- a/zerver/webhooks/ansibletower/view.py +++ b/zerver/webhooks/ansibletower/view.py @@ -1,14 +1,12 @@ -from typing import Any, Dict, Iterable, Optional, List +from typing import Any, Dict, List -from django.utils.translation import ugettext as _ from django.http import HttpRequest, HttpResponse from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.response import json_success, json_error +from zerver.lib.response import json_success from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.models import UserProfile -import ujson import operator ANSIBLETOWER_DEFAULT_MESSAGE_TEMPLATE = "{friendly_name}: [#{id} {name}]({url}) {status}\n" diff --git a/zerver/webhooks/appfollow/view.py b/zerver/webhooks/appfollow/view.py index b989581426..4e1c49b142 100644 --- a/zerver/webhooks/appfollow/view.py +++ b/zerver/webhooks/appfollow/view.py @@ -1,13 +1,12 @@ # Webhooks for external integrations. import re -from typing import Any, Dict, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/appveyor/view.py b/zerver/webhooks/appveyor/view.py index e86defb727..d26cbe1621 100644 --- a/zerver/webhooks/appveyor/view.py +++ b/zerver/webhooks/appveyor/view.py @@ -1,15 +1,12 @@ from typing import Any, Dict -from django.utils.translation import ugettext as _ from django.http import HttpRequest, HttpResponse from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.response import json_success, json_error +from zerver.lib.response import json_success from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.models import UserProfile -import ujson - APPVEYOR_TOPIC_TEMPLATE = '{project_name}' APPVEYOR_MESSAGE_TEMPLATE = ('[Build {project_name} {build_version} {status}]({build_url})\n' 'Commit [{commit_id}]({commit_url}) by {committer_name}' diff --git a/zerver/webhooks/basecamp/view.py b/zerver/webhooks/basecamp/view.py index 008b62670d..7d738caddb 100644 --- a/zerver/webhooks/basecamp/view.py +++ b/zerver/webhooks/basecamp/view.py @@ -1,4 +1,3 @@ -import logging import re from typing import Any, Dict @@ -6,7 +5,7 @@ from django.http import HttpRequest, HttpResponse from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType from zerver.models import UserProfile diff --git a/zerver/webhooks/beanstalk/view.py b/zerver/webhooks/beanstalk/view.py index 7573c09f5c..a4b6f20215 100644 --- a/zerver/webhooks/beanstalk/view.py +++ b/zerver/webhooks/beanstalk/view.py @@ -2,7 +2,7 @@ import base64 from functools import wraps -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Dict, Optional from django.http import HttpRequest, HttpResponse @@ -12,7 +12,7 @@ from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.validator import check_dict -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile from zerver.webhooks.github_legacy.view import build_message_from_gitlog # Beanstalk's web hook UI rejects url with a @ in the username section of a url diff --git a/zerver/webhooks/bitbucket/tests.py b/zerver/webhooks/bitbucket/tests.py index bf7f58539c..6254b8cffe 100644 --- a/zerver/webhooks/bitbucket/tests.py +++ b/zerver/webhooks/bitbucket/tests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from typing import Dict, Optional, Union +from typing import Dict, Union from mock import MagicMock, patch diff --git a/zerver/webhooks/bitbucket/view.py b/zerver/webhooks/bitbucket/view.py index 6b5289c052..6744c599c8 100644 --- a/zerver/webhooks/bitbucket/view.py +++ b/zerver/webhooks/bitbucket/view.py @@ -9,7 +9,7 @@ from zerver.lib.validator import check_dict from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \ get_push_commits_event_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile @authenticated_rest_api_view(webhook_client_name="Bitbucket") @has_request_variables diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket2/tests.py index 7174e5c5ee..44a8197531 100644 --- a/zerver/webhooks/bitbucket2/tests.py +++ b/zerver/webhooks/bitbucket2/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from typing import Optional - from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/bitbucket2/view.py b/zerver/webhooks/bitbucket2/view.py index 46304760f0..16fbd2cde2 100644 --- a/zerver/webhooks/bitbucket2/view.py +++ b/zerver/webhooks/bitbucket2/view.py @@ -1,15 +1,14 @@ # Webhooks for external integrations. import re from functools import partial -from typing import Any, Callable, Dict, List, Optional +from typing import Any, Dict, List, Optional from inspect import signature from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ validate_extract_webhook_http_header, UnexpectedWebhookEventType from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \ diff --git a/zerver/webhooks/circleci/view.py b/zerver/webhooks/circleci/view.py index 0ab588d885..bc306855b6 100644 --- a/zerver/webhooks/circleci/view.py +++ b/zerver/webhooks/circleci/view.py @@ -2,12 +2,11 @@ from typing import Any, Dict -import ujson from django.http import HttpRequest, HttpResponse from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/clubhouse/view.py b/zerver/webhooks/clubhouse/view.py index 33e6df9c5b..72f17416ec 100644 --- a/zerver/webhooks/clubhouse/view.py +++ b/zerver/webhooks/clubhouse/view.py @@ -1,5 +1,5 @@ from functools import partial -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Optional from django.http import HttpRequest, HttpResponse diff --git a/zerver/webhooks/codeship/view.py b/zerver/webhooks/codeship/view.py index b03a2fea65..0287014e2d 100644 --- a/zerver/webhooks/codeship/view.py +++ b/zerver/webhooks/codeship/view.py @@ -2,13 +2,11 @@ from typing import Any, Dict -import ujson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/crashlytics/view.py b/zerver/webhooks/crashlytics/view.py index 77e88987e1..def058a14a 100644 --- a/zerver/webhooks/crashlytics/view.py +++ b/zerver/webhooks/crashlytics/view.py @@ -2,11 +2,10 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/delighted/view.py b/zerver/webhooks/delighted/view.py index 8ad9ce7258..833253168b 100644 --- a/zerver/webhooks/delighted/view.py +++ b/zerver/webhooks/delighted/view.py @@ -1,11 +1,10 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/deskdotcom/view.py b/zerver/webhooks/deskdotcom/view.py index f9f49ae5ee..b2c7f3454d 100644 --- a/zerver/webhooks/deskdotcom/view.py +++ b/zerver/webhooks/deskdotcom/view.py @@ -6,7 +6,7 @@ from zerver.decorator import authenticated_rest_api_view from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile # Desk.com's integrations all make the user supply a template, where it fills # in stuff like {{customer.name}} and posts the result as a "data" parameter. diff --git a/zerver/webhooks/dropbox/view.py b/zerver/webhooks/dropbox/view.py index ba64df8e91..545feb7640 100644 --- a/zerver/webhooks/dropbox/view.py +++ b/zerver/webhooks/dropbox/view.py @@ -1,7 +1,7 @@ from django.http import HttpRequest, HttpResponse from zerver.lib.response import json_success 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.decorator import has_request_variables, api_key_only_webhook_view from zerver.models import UserProfile @api_key_only_webhook_view('Dropbox', notify_bot_owner_on_invalid_json=False) diff --git a/zerver/webhooks/freshdesk/view.py b/zerver/webhooks/freshdesk/view.py index 9f587fe37a..003dcd2da9 100644 --- a/zerver/webhooks/freshdesk/view.py +++ b/zerver/webhooks/freshdesk/view.py @@ -1,9 +1,8 @@ """Webhooks for external integrations.""" import logging -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List -import ujson from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ @@ -12,7 +11,7 @@ from zerver.lib.notifications import convert_html_to_markdown from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_error, json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile class TicketDict(Dict[str, Any]): """ diff --git a/zerver/webhooks/front/view.py b/zerver/webhooks/front/view.py index 56f53a3a71..47e3fa7e48 100644 --- a/zerver/webhooks/front/view.py +++ b/zerver/webhooks/front/view.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Tuple +from typing import Any, Dict, Tuple from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ diff --git a/zerver/webhooks/gci/tests.py b/zerver/webhooks/gci/tests.py index 49a8ac3949..f7c1958e8e 100644 --- a/zerver/webhooks/gci/tests.py +++ b/zerver/webhooks/gci/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from typing import Optional - from zerver.lib.test_classes import WebhookTestCase class GoogleCodeInTests(WebhookTestCase): diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py index 5d13cdb20c..8606a2c4dd 100644 --- a/zerver/webhooks/github/tests.py +++ b/zerver/webhooks/github/tests.py @@ -1,11 +1,7 @@ -from typing import Dict, Optional - -import ujson from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase from zerver.lib.webhooks.git import COMMITS_LIMIT -from zerver.models import Message class GithubWebhookTest(WebhookTestCase): STREAM_NAME = 'github' diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py index 300a9db4a4..a5d31a3cd7 100644 --- a/zerver/webhooks/github/view.py +++ b/zerver/webhooks/github/view.py @@ -1,13 +1,12 @@ -import logging import re from functools import partial -from typing import Any, Callable, Dict, Optional +from typing import Any, Dict, Optional from inspect import signature from django.http import HttpRequest, HttpResponse from zerver.decorator import api_key_only_webhook_view -from zerver.lib.request import REQ, JsonableError, has_request_variables +from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ validate_extract_webhook_http_header, UnexpectedWebhookEventType diff --git a/zerver/webhooks/github_legacy/view.py b/zerver/webhooks/github_legacy/view.py index d77668dc8c..20b67990b0 100644 --- a/zerver/webhooks/github_legacy/view.py +++ b/zerver/webhooks/github_legacy/view.py @@ -1,6 +1,6 @@ import logging import re -from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple +from typing import Any, Dict, List, Mapping, Optional, Tuple import ujson from django.conf import settings diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.py index 25d632de11..e065025c80 100644 --- a/zerver/webhooks/gitlab/tests.py +++ b/zerver/webhooks/gitlab/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from typing import Optional - from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/gitlab/view.py b/zerver/webhooks/gitlab/view.py index d6e97a4a82..72bdf229a1 100644 --- a/zerver/webhooks/gitlab/view.py +++ b/zerver/webhooks/gitlab/view.py @@ -1,5 +1,5 @@ from functools import partial -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Optional from inspect import signature import re diff --git a/zerver/webhooks/gocd/tests.py b/zerver/webhooks/gocd/tests.py index aa9ba3d42b..e837e043cd 100644 --- a/zerver/webhooks/gocd/tests.py +++ b/zerver/webhooks/gocd/tests.py @@ -1,8 +1,5 @@ # -*- coding: utf-8 -*- -import urllib - from zerver.lib.test_classes import WebhookTestCase -from zerver.models import get_realm, get_user class GocdHookTests(WebhookTestCase): STREAM_NAME = 'gocd' diff --git a/zerver/webhooks/gocd/view.py b/zerver/webhooks/gocd/view.py index 4299511efc..4a4ab9e946 100644 --- a/zerver/webhooks/gocd/view.py +++ b/zerver/webhooks/gocd/view.py @@ -3,16 +3,14 @@ import json import os -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.validator import check_dict, check_string from zerver.models import UserProfile MESSAGE_TEMPLATE = ( diff --git a/zerver/webhooks/gogs/tests.py b/zerver/webhooks/gogs/tests.py index f6d3643809..507ba0f04b 100644 --- a/zerver/webhooks/gogs/tests.py +++ b/zerver/webhooks/gogs/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from typing import Optional - from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/gogs/view.py b/zerver/webhooks/gogs/view.py index d20b0d02fe..4ad6e9ccb2 100644 --- a/zerver/webhooks/gogs/view.py +++ b/zerver/webhooks/gogs/view.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- # vim:fenc=utf-8 -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Optional from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ validate_extract_webhook_http_header, UnexpectedWebhookEventType from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \ diff --git a/zerver/webhooks/gosquared/view.py b/zerver/webhooks/gosquared/view.py index ca4d9dd50d..b0ce9fc055 100644 --- a/zerver/webhooks/gosquared/view.py +++ b/zerver/webhooks/gosquared/view.py @@ -1,11 +1,10 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType from zerver.models import UserProfile diff --git a/zerver/webhooks/greenhouse/view.py b/zerver/webhooks/greenhouse/view.py index b1d8edaf1c..3d6c28df50 100644 --- a/zerver/webhooks/greenhouse/view.py +++ b/zerver/webhooks/greenhouse/view.py @@ -1,12 +1,10 @@ from typing import Any, Dict, List -import ujson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/hellosign/view.py b/zerver/webhooks/hellosign/view.py index 9ba0815e69..0d0b898973 100644 --- a/zerver/webhooks/hellosign/view.py +++ b/zerver/webhooks/hellosign/view.py @@ -1,11 +1,10 @@ from typing import Any, Dict, List from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/helloworld/view.py b/zerver/webhooks/helloworld/view.py index efab36693f..5fc6cff0ba 100644 --- a/zerver/webhooks/helloworld/view.py +++ b/zerver/webhooks/helloworld/view.py @@ -1,14 +1,12 @@ # Webhooks for external integrations. -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Iterable from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success -from zerver.lib.validator import check_dict, check_string +from zerver.lib.response import json_success from zerver.models import UserProfile @api_key_only_webhook_view('HelloWorld') diff --git a/zerver/webhooks/homeassistant/view.py b/zerver/webhooks/homeassistant/view.py index 79ba18fa90..ca354ba54d 100644 --- a/zerver/webhooks/homeassistant/view.py +++ b/zerver/webhooks/homeassistant/view.py @@ -1,13 +1,11 @@ -from typing import Any, Dict, Iterable, Optional +from typing import Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.validator import check_dict, check_string from zerver.models import UserProfile @api_key_only_webhook_view('HomeAssistant') diff --git a/zerver/webhooks/ifttt/view.py b/zerver/webhooks/ifttt/view.py index 2bf43add06..af6749a3cd 100644 --- a/zerver/webhooks/ifttt/view.py +++ b/zerver/webhooks/ifttt/view.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict +from typing import Any, Dict from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ diff --git a/zerver/webhooks/insping/view.py b/zerver/webhooks/insping/view.py index e5e587d043..57ab1b6403 100644 --- a/zerver/webhooks/insping/view.py +++ b/zerver/webhooks/insping/view.py @@ -1,14 +1,12 @@ -from django.utils.translation import ugettext as _ -from zerver.lib.response import json_success, json_error +from zerver.lib.response import json_success 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.lib.validator import check_dict, check_string -from zerver.models import Client, UserProfile +from zerver.models import UserProfile from django.http import HttpRequest, HttpResponse -from typing import Dict, Any, Iterable, Optional +from typing import Dict, Any import time diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.py index 76af830842..d00ea5302d 100644 --- a/zerver/webhooks/jira/view.py +++ b/zerver/webhooks/jira/view.py @@ -1,17 +1,13 @@ # Webhooks for external integrations. -import logging import re -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Dict, List, Optional -import ujson -from django.conf import settings from django.db.models import Q from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType from zerver.models import Realm, UserProfile, get_user_by_delivery_email diff --git a/zerver/webhooks/librato/tests.py b/zerver/webhooks/librato/tests.py index a0e2a57821..0bc8d516f6 100644 --- a/zerver/webhooks/librato/tests.py +++ b/zerver/webhooks/librato/tests.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import urllib -from typing import Optional from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/librato/view.py b/zerver/webhooks/librato/view.py index 33e1b40662..4cbbddc4c2 100644 --- a/zerver/webhooks/librato/view.py +++ b/zerver/webhooks/librato/view.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Any, Callable, Dict, List, Tuple import ujson from django.http import HttpRequest, HttpResponse diff --git a/zerver/webhooks/mention/view.py b/zerver/webhooks/mention/view.py index 23b8f7a89f..5605efaba6 100644 --- a/zerver/webhooks/mention/view.py +++ b/zerver/webhooks/mention/view.py @@ -1,14 +1,12 @@ # Webhooks for external integrations. -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Iterable from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.validator import check_dict, check_string from zerver.models import UserProfile @api_key_only_webhook_view('Mention') diff --git a/zerver/webhooks/netlify/tests.py b/zerver/webhooks/netlify/tests.py index 5ba64d5ad1..ff7260f3dc 100644 --- a/zerver/webhooks/netlify/tests.py +++ b/zerver/webhooks/netlify/tests.py @@ -1,8 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf import settings - from zerver.lib.test_classes import WebhookTestCase -from zerver.models import get_system_bot class NetlifyHookTests(WebhookTestCase): STREAM_NAME = 'netlify' diff --git a/zerver/webhooks/netlify/view.py b/zerver/webhooks/netlify/view.py index 872e0cd13c..afb0dbca3c 100644 --- a/zerver/webhooks/netlify/view.py +++ b/zerver/webhooks/netlify/view.py @@ -1,14 +1,12 @@ -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Iterable from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.webhooks.common import check_send_webhook_message, \ validate_extract_webhook_http_header, UnexpectedWebhookEventType from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success -from zerver.lib.validator import check_dict, check_string +from zerver.lib.response import json_success from zerver.models import UserProfile EVENTS = ['deploy_failed', 'deploy_locked', 'deploy_unlocked', 'deploy_building', 'deploy_created'] diff --git a/zerver/webhooks/newrelic/view.py b/zerver/webhooks/newrelic/view.py index 6b96c72ca7..b335d8ec3d 100644 --- a/zerver/webhooks/newrelic/view.py +++ b/zerver/webhooks/newrelic/view.py @@ -1,16 +1,15 @@ # Webhooks for external integrations. -from typing import Any, Callable, Dict, Iterable, Optional, Tuple +from typing import Any, Dict, Optional from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType from zerver.lib.validator import check_dict -from zerver.models import Stream, UserProfile +from zerver.models import UserProfile @api_key_only_webhook_view("NewRelic") @has_request_variables diff --git a/zerver/webhooks/opbeat/view.py b/zerver/webhooks/opbeat/view.py index 90ff888faa..d9b7daafb2 100644 --- a/zerver/webhooks/opbeat/view.py +++ b/zerver/webhooks/opbeat/view.py @@ -1,5 +1,5 @@ # Webhooks for external integrations. -from typing import Dict, Any, List, Tuple, Union +from typing import Dict, Any, List from django.http import HttpRequest, HttpResponse @@ -7,7 +7,7 @@ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile subject_types = { 'app': [ # Object type name diff --git a/zerver/webhooks/opsgenie/view.py b/zerver/webhooks/opsgenie/view.py index 6f6c21b449..6dd2e1dda2 100644 --- a/zerver/webhooks/opsgenie/view.py +++ b/zerver/webhooks/opsgenie/view.py @@ -1,13 +1,11 @@ -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.validator import check_dict, check_string from zerver.models import UserProfile @api_key_only_webhook_view('OpsGenie') diff --git a/zerver/webhooks/pagerduty/view.py b/zerver/webhooks/pagerduty/view.py index 573650b719..a4e27c1b9d 100644 --- a/zerver/webhooks/pagerduty/view.py +++ b/zerver/webhooks/pagerduty/view.py @@ -1,6 +1,6 @@ # Webhooks for external integrations. -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Iterable from django.http import HttpRequest, HttpResponse @@ -9,7 +9,7 @@ from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType -from zerver.models import Client, UserProfile +from zerver.models import UserProfile PAGER_DUTY_EVENT_NAMES = { 'incident.trigger': 'triggered', diff --git a/zerver/webhooks/papertrail/view.py b/zerver/webhooks/papertrail/view.py index d29375da86..21002315ae 100644 --- a/zerver/webhooks/papertrail/view.py +++ b/zerver/webhooks/papertrail/view.py @@ -1,13 +1,11 @@ -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.validator import check_dict, check_string from zerver.models import UserProfile @api_key_only_webhook_view('Papertrail') diff --git a/zerver/webhooks/pingdom/view.py b/zerver/webhooks/pingdom/view.py index 1c510c5ee9..94b0dbf6b8 100644 --- a/zerver/webhooks/pingdom/view.py +++ b/zerver/webhooks/pingdom/view.py @@ -1,13 +1,11 @@ # Webhooks pfor external integrations. from typing import Any, Dict -import ujson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType from zerver.models import UserProfile diff --git a/zerver/webhooks/pivotal/view.py b/zerver/webhooks/pivotal/view.py index b481b420ea..2f663072e4 100644 --- a/zerver/webhooks/pivotal/view.py +++ b/zerver/webhooks/pivotal/view.py @@ -1,6 +1,5 @@ """Webhooks for external integrations.""" -import logging import re from typing import Any, Dict, List, Optional, Tuple @@ -10,7 +9,7 @@ from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view -from zerver.lib.request import REQ, has_request_variables +from zerver.lib.request import has_request_variables from zerver.lib.response import json_error, json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType diff --git a/zerver/webhooks/raygun/view.py b/zerver/webhooks/raygun/view.py index c5cebdf805..3b04f7d6d4 100644 --- a/zerver/webhooks/raygun/view.py +++ b/zerver/webhooks/raygun/view.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse diff --git a/zerver/webhooks/reviewboard/tests.py b/zerver/webhooks/reviewboard/tests.py index 257ae1179b..9cb01fda09 100644 --- a/zerver/webhooks/reviewboard/tests.py +++ b/zerver/webhooks/reviewboard/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from typing import Optional - from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/reviewboard/view.py b/zerver/webhooks/reviewboard/view.py index fcf0a7eb5d..8ba4e71d60 100644 --- a/zerver/webhooks/reviewboard/view.py +++ b/zerver/webhooks/reviewboard/view.py @@ -1,14 +1,12 @@ -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict, Iterable from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.webhooks.common import check_send_webhook_message, \ validate_extract_webhook_http_header, UnexpectedWebhookEventType from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success -from zerver.lib.validator import check_dict, check_string +from zerver.lib.response import json_success from zerver.models import UserProfile REVIEW_REQUEST_PUBLISHED = """ diff --git a/zerver/webhooks/semaphore/view.py b/zerver/webhooks/semaphore/view.py index 8002bd6eaa..d20d6b6671 100644 --- a/zerver/webhooks/semaphore/view.py +++ b/zerver/webhooks/semaphore/view.py @@ -2,15 +2,13 @@ from typing import Any, Dict -import ujson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile @api_key_only_webhook_view('Semaphore') @has_request_variables diff --git a/zerver/webhooks/slack/view.py b/zerver/webhooks/slack/view.py index 5cc036435d..b0e8636f77 100644 --- a/zerver/webhooks/slack/view.py +++ b/zerver/webhooks/slack/view.py @@ -1,12 +1,10 @@ -from django.http import HttpRequest, HttpResponse +from django.http import HttpRequest from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view -from zerver.lib.actions import check_send_stream_message, \ - create_stream_if_needed +from zerver.lib.actions import check_send_stream_message from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_error, json_success -from zerver.lib.validator import check_int, check_string from zerver.models import UserProfile ZULIP_MESSAGE_TEMPLATE = u"**{message_sender}**: `{text}`" diff --git a/zerver/webhooks/solano/tests.py b/zerver/webhooks/solano/tests.py index 03eeb592d4..d40f245d56 100644 --- a/zerver/webhooks/solano/tests.py +++ b/zerver/webhooks/solano/tests.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -import urllib - from zerver.lib.test_classes import WebhookTestCase class SolanoHookTests(WebhookTestCase): diff --git a/zerver/webhooks/solano/view.py b/zerver/webhooks/solano/view.py index c1e3effc17..a70d66e029 100644 --- a/zerver/webhooks/solano/view.py +++ b/zerver/webhooks/solano/view.py @@ -3,13 +3,12 @@ from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import Client, UserProfile +from zerver.models import UserProfile @api_key_only_webhook_view('SolanoLabs') @has_request_variables diff --git a/zerver/webhooks/splunk/view.py b/zerver/webhooks/splunk/view.py index 2aaf38fbae..8a06aae2ca 100644 --- a/zerver/webhooks/splunk/view.py +++ b/zerver/webhooks/splunk/view.py @@ -1,14 +1,12 @@ # Webhooks for external integrations. -from typing import Any, Dict, Iterable, Optional +from typing import Any, Dict from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.lib.validator import check_dict, check_string from zerver.models import MAX_TOPIC_NAME_LENGTH, UserProfile @api_key_only_webhook_view('Splunk') diff --git a/zerver/webhooks/statuspage/view.py b/zerver/webhooks/statuspage/view.py index 0a7d1a74fa..1584cae574 100644 --- a/zerver/webhooks/statuspage/view.py +++ b/zerver/webhooks/statuspage/view.py @@ -1,9 +1,8 @@ # Webhooks for external integrations. -from django.utils.translation import ugettext as _ from zerver.lib.response import json_success 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 zerver.models import UserProfile from django.http import HttpRequest, HttpResponse from typing import Dict, Any diff --git a/zerver/webhooks/stripe/view.py b/zerver/webhooks/stripe/view.py index f5ac0c6fa4..b523573893 100644 --- a/zerver/webhooks/stripe/view.py +++ b/zerver/webhooks/stripe/view.py @@ -1,14 +1,12 @@ # Webhooks for external integrations. import time -from datetime import datetime from typing import Any, Dict, List, Optional, Tuple from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.timestamp import timestamp_to_datetime from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType diff --git a/zerver/webhooks/taiga/view.py b/zerver/webhooks/taiga/view.py index 807b044de2..ce32c32117 100644 --- a/zerver/webhooks/taiga/view.py +++ b/zerver/webhooks/taiga/view.py @@ -9,13 +9,11 @@ should be in bold. from typing import Any, Dict, List, Mapping, Optional, Tuple -import ujson from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile diff --git a/zerver/webhooks/teamcity/view.py b/zerver/webhooks/teamcity/view.py index f7ecdb70fc..ec816db82d 100644 --- a/zerver/webhooks/teamcity/view.py +++ b/zerver/webhooks/teamcity/view.py @@ -3,7 +3,6 @@ import logging from typing import Any, Dict, List, Optional -import ujson from django.db.models import Q from django.http import HttpRequest, HttpResponse @@ -12,7 +11,7 @@ from zerver.lib.actions import check_send_private_message, \ send_rate_limited_pm_notification_to_bot_owner from zerver.lib.send_email import FromAddress from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import Realm, UserProfile diff --git a/zerver/webhooks/transifex/view.py b/zerver/webhooks/transifex/view.py index 14f0d27806..0afd537eac 100644 --- a/zerver/webhooks/transifex/view.py +++ b/zerver/webhooks/transifex/view.py @@ -2,11 +2,10 @@ from typing import Optional from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType from zerver.models import UserProfile diff --git a/zerver/webhooks/travis/tests.py b/zerver/webhooks/travis/tests.py index dc8a163ec3..b16e2c8903 100644 --- a/zerver/webhooks/travis/tests.py +++ b/zerver/webhooks/travis/tests.py @@ -2,7 +2,6 @@ import urllib from zerver.lib.test_classes import WebhookTestCase -from zerver.models import get_realm, get_user class TravisHookTests(WebhookTestCase): STREAM_NAME = 'travis' diff --git a/zerver/webhooks/travis/view.py b/zerver/webhooks/travis/view.py index e430ce3a0f..9ea67aeca1 100644 --- a/zerver/webhooks/travis/view.py +++ b/zerver/webhooks/travis/view.py @@ -2,7 +2,6 @@ from typing import Dict -import ujson from django.http import HttpRequest, HttpResponse from zerver.decorator import api_key_only_webhook_view diff --git a/zerver/webhooks/trello/view/__init__.py b/zerver/webhooks/trello/view/__init__.py index d600c29664..1c896edbf4 100644 --- a/zerver/webhooks/trello/view/__init__.py +++ b/zerver/webhooks/trello/view/__init__.py @@ -1,10 +1,9 @@ # Webhooks for external integrations. import ujson from typing import Mapping, Any, Tuple, Optional -from django.utils.translation import ugettext as _ from django.http import HttpRequest, HttpResponse from zerver.decorator import api_key_only_webhook_view, return_success_on_head_request -from zerver.lib.response import json_success, json_error +from zerver.lib.response import json_success from zerver.lib.request import REQ, has_request_variables from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType diff --git a/zerver/webhooks/trello/view/board_actions.py b/zerver/webhooks/trello/view/board_actions.py index 9d5925d9eb..8976fbf1c9 100644 --- a/zerver/webhooks/trello/view/board_actions.py +++ b/zerver/webhooks/trello/view/board_actions.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Mapping, MutableMapping, Optional, Tuple +from typing import Any, Dict, Mapping, Optional, Tuple from .exceptions import UnknownUpdateBoardAction diff --git a/zerver/webhooks/trello/view/card_actions.py b/zerver/webhooks/trello/view/card_actions.py index dd9bbd5520..c5c4941041 100644 --- a/zerver/webhooks/trello/view/card_actions.py +++ b/zerver/webhooks/trello/view/card_actions.py @@ -1,5 +1,4 @@ -from datetime import datetime -from typing import Any, Dict, Mapping, MutableMapping, Optional, Tuple +from typing import Any, Dict, Mapping, Optional, Tuple from .exceptions import UnknownUpdateCardAction diff --git a/zerver/webhooks/updown/view.py b/zerver/webhooks/updown/view.py index ca3f0c3ba2..c5acc457dd 100644 --- a/zerver/webhooks/updown/view.py +++ b/zerver/webhooks/updown/view.py @@ -1,18 +1,15 @@ # Webhooks for external integrations. import re -from datetime import datetime from typing import Any, Dict, List from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.decorator import api_key_only_webhook_view -from zerver.lib.exceptions import JsonableError from zerver.lib.request import REQ, has_request_variables -from zerver.lib.response import json_error, json_success +from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message, \ UnexpectedWebhookEventType -from zerver.models import Client, UserProfile +from zerver.models import UserProfile TOPIC_TEMPLATE = "{service_url}" diff --git a/zerver/webhooks/wordpress/tests.py b/zerver/webhooks/wordpress/tests.py index e04ab3795c..fd48eb3674 100644 --- a/zerver/webhooks/wordpress/tests.py +++ b/zerver/webhooks/wordpress/tests.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase -from zerver.models import get_realm, get_user class WordPressHookTests(WebhookTestCase): STREAM_NAME = 'wordpress' diff --git a/zerver/webhooks/wordpress/view.py b/zerver/webhooks/wordpress/view.py index ade90a9c79..3280cb52a6 100644 --- a/zerver/webhooks/wordpress/view.py +++ b/zerver/webhooks/wordpress/view.py @@ -6,7 +6,7 @@ from zerver.decorator import api_key_only_webhook_view from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_error, json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile PUBLISH_POST_OR_PAGE_TEMPLATE = 'New {type} published.\n[{title}]({url})' USER_REGISTER_TEMPLATE = 'New blog user registered.\nName: {name}\nemail: {email}' diff --git a/zerver/webhooks/yo/view.py b/zerver/webhooks/yo/view.py index c0fdca8079..2cf430d40b 100644 --- a/zerver/webhooks/yo/view.py +++ b/zerver/webhooks/yo/view.py @@ -1,7 +1,6 @@ # Webhooks for external integrations. from typing import Optional -import ujson from django.http import HttpRequest, HttpResponse from zerver.decorator import api_key_only_webhook_view diff --git a/zerver/webhooks/zabbix/view.py b/zerver/webhooks/zabbix/view.py index c42aa16042..1b53e37945 100644 --- a/zerver/webhooks/zabbix/view.py +++ b/zerver/webhooks/zabbix/view.py @@ -10,8 +10,6 @@ from zerver.lib.send_email import FromAddress from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.models import UserProfile -import ujson - MISCONFIGURED_PAYLOAD_ERROR_MESSAGE = """ Hi there! Your bot {bot_name} just received a Zabbix payload that is missing some data that Zulip requires. This usually indicates a configuration issue diff --git a/zerver/webhooks/zapier/view.py b/zerver/webhooks/zapier/view.py index 1a45412267..a83844f87d 100644 --- a/zerver/webhooks/zapier/view.py +++ b/zerver/webhooks/zapier/view.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, Dict +from typing import Any, Dict from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ diff --git a/zerver/webhooks/zendesk/view.py b/zerver/webhooks/zendesk/view.py index c046542ffc..3026a948f4 100644 --- a/zerver/webhooks/zendesk/view.py +++ b/zerver/webhooks/zendesk/view.py @@ -6,7 +6,7 @@ from zerver.decorator import authenticated_rest_api_view from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message -from zerver.models import UserProfile, get_client +from zerver.models import UserProfile def truncate(string: str, length: int) -> str: if len(string) > length: