Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
python: Remove locally dead code.
Anders Kaseorg4206e5f00b54
diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex 4aa853d7707..e1f9b7590f2 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -352,15 +352,8 @@ def mock_stripe(return _mock_stripe-# A Kandra is a fictional character that can become anything. Used as a-# wildcard when testing for equality.-class Kandra: # nocoverage: TODO- def __eq__(self, other: Any) -> bool:- return True--class StripeTestCase(ZulipTestCase):- def setUp(self, *mocks: Mock) -> None:+ def setUp(self) -> None:super().setUp()realm = get_realm("zulip")@@ -2381,7 +2374,7 @@ class StripeTest(StripeTestCase):invoice_plans_as_needed(self.next_year)mocked.assert_not_called()- def test_reupgrade_by_billing_admin_after_downgrade(self, *mocks: Mock) -> None:+ def test_reupgrade_by_billing_admin_after_downgrade(self) -> None:user = self.example_user("hamlet")with patch("corporate.lib.stripe.timezone_now", return_value=self.now):@@ -2557,7 +2550,7 @@ class StripeTest(StripeTestCase):for key, value in line_item_params.items():self.assertEqual(renewal_item.get(key), value)- def test_update_licenses_of_automatic_plan_from_billing_page(self, *mocks: Mock) -> None:+ def test_update_licenses_of_automatic_plan_from_billing_page(self) -> None:user = self.example_user("hamlet")self.login_user(user)diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2index 5aae283d32f..58b406163ae 100755--- a/scripts/lib/upgrade-zulip-stage-2+++ b/scripts/lib/upgrade-zulip-stage-2@@ -30,7 +30,6 @@ from scripts.lib.zulip_tools import (assert_running_as_root,get_config,get_config_file,- get_tornado_ports,parse_os_release,run_psql_as_postgres,su_to_zulip,@@ -97,7 +96,6 @@ deploy_path = args.deploy_pathos.chdir(deploy_path)config_file = get_config_file()-tornado_processes = len(get_tornado_ports(config_file))IS_SERVER_UP = Truediff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.pyindex aba9edfb96e..1f7094e2614 100755--- a/scripts/lib/zulip_tools.py+++ b/scripts/lib/zulip_tools.py@@ -555,17 +555,6 @@ def get_config(return default_value-def set_config(- config_file: configparser.RawConfigParser,- section: str,- key: str,- value: str,-) -> None:- if not config_file.has_section(section):- config_file.add_section(section)- config_file.set(section, key, value)--def get_config_file() -> configparser.RawConfigParser:config_file = configparser.RawConfigParser()config_file.read("/etc/zulip/zulip.conf")diff --git a/scripts/setup/inline_email_css.py b/scripts/setup/inline_email_css.pyindex 170572a954e..0dd5b89798c 100755--- a/scripts/setup/inline_email_css.py+++ b/scripts/setup/inline_email_css.py@@ -8,7 +8,6 @@ from premailer import PremailerZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../")EMAIL_TEMPLATES_PATH = os.path.join(ZULIP_PATH, "templates", "zerver", "emails")-COMPILED_EMAIL_TEMPLATES_PATH = os.path.join(EMAIL_TEMPLATES_PATH, "compiled")CSS_SOURCE_PATH = os.path.join(EMAIL_TEMPLATES_PATH, "email.css")diff --git a/templates/zerver/api/incoming-webhooks-walkthrough.md b/templates/zerver/api/incoming-webhooks-walkthrough.mdindex d2d68ab84fc..d329db88eec 100644--- a/templates/zerver/api/incoming-webhooks-walkthrough.md+++ b/templates/zerver/api/incoming-webhooks-walkthrough.md@@ -320,7 +320,7 @@ class `HelloWorldHookTests`:class HelloWorldHookTests(WebhookTestCase):STREAM_NAME = 'test'URL_TEMPLATE = "/api/v1/external/helloworld?&api_key={api_key}"- FIXTURE_DIR_NAME = 'helloworld'+ WEBHOOK_DIR_NAME = 'helloworld'# Note: Include a test function per each distinct message condition your integration supportsdef test_hello_message(self) -> None:@@ -333,7 +333,7 @@ class HelloWorldHookTests(WebhookTestCase):```-In the above example, `STREAM_NAME`, `URL_TEMPLATE`, and `FIXTURE_DIR_NAME` refer+In the above example, `STREAM_NAME`, `URL_TEMPLATE`, and `WEBHOOK_DIR_NAME` referto class attributes from the base class, `WebhookTestCase`. These are needed bythe helper function `check_webhook` to determine how to executeyour test. `STREAM_NAME` should be set to your default stream. If it doesn't exist,diff --git a/tools/check-templates b/tools/check-templatesindex 0176fc49cf9..053dc4f243e 100755--- a/tools/check-templates+++ b/tools/check-templates@@ -34,7 +34,7 @@ EXCLUDED_FILES = [def check_our_files(modified_only: bool, all_dups: bool, fix: bool, targets: List[str]) -> None:by_lang = lister.list_files(targets=targets,- modified_only=args.modified,+ modified_only=modified_only,ftypes=["hbs", "html"],group_by_ftype=True,exclude=EXCLUDED_FILES,diff --git a/tools/create-test-api-docs b/tools/create-test-api-docsindex f0fc6351c89..6f3e1af48ed 100755--- a/tools/create-test-api-docs+++ b/tools/create-test-api-docs@@ -2,7 +2,6 @@import htmlimport os-import pprintimport sysfrom collections import defaultdictfrom typing import Any, Dict, List, Set@@ -40,25 +39,6 @@ def clean_up_pattern(s: str) -> str:return result-def encode_info(info: Any) -> str:- try:- result = ""- try:- info = orjson.loads(info)- result = "(stringified)\n"- except orjson.JSONDecodeError:- pass- result += html.escape(pprint.pformat(info, indent=4))- return "<pre>" + result + "</pre>"- except Exception:- pass- try:- return html.escape(str(info))- except Exception:- pass- return "NOT ENCODABLE"--def fix_test_name(s: str) -> str:return s.replace("zerver.tests.", "")diff --git a/tools/lib/html_branches.py b/tools/lib/html_branches.pyindex 8d0301ec020..661e008268c 100644--- a/tools/lib/html_branches.py+++ b/tools/lib/html_branches.py@@ -5,11 +5,6 @@ from typing import Dict, List, Optional, Sequence, Setfrom .template_parser import FormattedException, Token, tokenize-class HtmlBranchesException(Exception):- # TODO: Have callers pass in line numbers.- pass--class HtmlTreeBranch:"""For <p><div id='yo'>bla<span class='bar'></span></div></p>, store adiff --git a/tools/lib/provision.py b/tools/lib/provision.pyindex ba185178682..b64e94e7eba 100755--- a/tools/lib/provision.py+++ b/tools/lib/provision.py@@ -76,18 +76,6 @@ except OSError:)sys.exit(1)-if platform.architecture()[0] == "64bit":- arch = "amd64"-elif platform.architecture()[0] == "32bit":- arch = "i386"-else:- logging.critical(- "Only x86 is supported; ask on chat.zulip.org if you want another architecture."- )- # Note: It's probably actually not hard to add additional- # architectures.- sys.exit(1)-distro_info = parse_os_release()vendor = distro_info["ID"]os_version = distro_info["VERSION_ID"]diff --git a/tools/run-dev.py b/tools/run-dev.pyindex 1e3990c8f3f..f21d6fa5871 100755--- a/tools/run-dev.py+++ b/tools/run-dev.py@@ -90,7 +90,7 @@ else:manage_args = [f"--settings={settings_module}"]os.environ["DJANGO_SETTINGS_MODULE"] = settings_module-from scripts.lib.zulip_tools import CYAN, ENDC, FAIL+from scripts.lib.zulip_tools import CYAN, ENDCproxy_port = base_portdjango_port = base_port + 1@@ -310,15 +310,6 @@ class TornadoHandler(BaseHandler):target_port = tornado_port-class ErrorHandler(BaseHandler):- @web.asynchronous- def prepare(self) -> None:- print(FAIL + "Unexpected request: " + ENDC, self.request.path)- self.set_status(500)- self.write("path not supported")- self.finish()--class Application(web.Application):def __init__(self, enable_logging: bool = False) -> None:handlers = [@@ -334,10 +325,6 @@ class Application(web.Application):super().log_request(handler)-def on_shutdown() -> None:- IOLoop.instance().stop()--def shutdown_handler(*args: Any, **kwargs: Any) -> None:io_loop = IOLoop.instance()if io_loop._callbacks:diff --git a/tools/setup/emoji/build_emoji b/tools/setup/emoji/build_emojiindex e3a6d04f789..0b7d0f2facb 100755--- a/tools/setup/emoji/build_emoji+++ b/tools/setup/emoji/build_emoji@@ -265,7 +265,7 @@ def setup_emoji_farms(cache_path: str, emoji_data: List[Dict[str, Any]]) -> Noneif emoji_dict["has_img_" + alt_name]:ensure_emoji_image(emoji_dict, src_emoji_farm, target_emoji_farm)skin_variations = emoji_dict.get("skin_variations", {})- for skin_tone, img_info in skin_variations.items():+ for img_info in skin_variations.values():if img_info["has_img_" + alt_name]:ensure_emoji_image(img_info, src_emoji_farm, target_emoji_farm)diff --git a/tools/setup/emoji/generate_emoji_names_table b/tools/setup/emoji/generate_emoji_names_tableindex a72d80530eb..aeaab241f94 100755--- a/tools/setup/emoji/generate_emoji_names_table+++ b/tools/setup/emoji/generate_emoji_names_table@@ -15,7 +15,6 @@ from emoji_setup_utils import EMOJISETS, emoji_is_universal, get_emoji_codeTOOLS_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))ZULIP_PATH = os.path.dirname(TOOLS_DIR)-EMOJI_MAP_FILE = os.path.join(TOOLS_DIR, "setup", "emoji", "emoji_map.json")UNIFIED_REACTIONS_FILE = os.path.join(ZULIP_PATH, "zerver", "management", "data", "unified_reactions.json")@@ -27,8 +26,6 @@ with open(EMOJI_DATA_FILE, "rb") as fp:EMOJI_DATA = orjson.loads(fp.read())with open(UNIFIED_REACTIONS_FILE, "rb") as fp:UNIFIED_REACTIONS_MAP = orjson.loads(fp.read())-with open(EMOJI_MAP_FILE, "rb") as fp:- EMOJI_MAP = orjson.loads(fp.read())EMOJI_IMAGE_TEMPLATE = """<img class="emoji" src="images-{emojiset}-64/{emoji_code}.png" title={emojiset}>diff --git a/tools/test-api b/tools/test-apiindex 32f8f16b55f..8e5e268fbf0 100755--- a/tools/test-api+++ b/tools/test-api@@ -82,17 +82,6 @@ with test_server_running(site=site,)- # Prepare a generic bot client for curl testing- email = "[email protected]"- realm = get_realm("zulip")- bot_user = get_user(email, realm)- api_key = get_api_key(bot_user)- bot_client = Client(- email=email,- api_key=api_key,- site=site,- )-# Prepare the non-admin clientemail = "[email protected]" # guest is not an adminguest_user = do_create_user(diff --git a/tools/webpack b/tools/webpackindex 9d36dc91c97..fc75b3a694c 100755--- a/tools/webpack+++ b/tools/webpack@@ -6,7 +6,6 @@ import subprocessfrom typing import NoReturnos.chdir(os.path.join(os.path.dirname(__file__), ".."))-STATIC_PATH = "static/"def build_for_prod_or_puppeteer(quiet: bool) -> NoReturn:diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.pyindex bf6b8f4159f..9b85e27d88f 100644--- a/zerver/data_import/import_util.py+++ b/zerver/data_import/import_util.py@@ -192,42 +192,6 @@ def build_subscription(recipient_id: int, user_id: int, subscription_id: int) ->return subscription_dict-def build_public_stream_subscriptions(- zerver_userprofile: List[ZerverFieldsT],- zerver_recipient: List[ZerverFieldsT],- zerver_stream: List[ZerverFieldsT],-) -> List[ZerverFieldsT]:- """- This function was only used for HipChat, but it may apply to- future conversions. We often did't get full subscriber data in- the HipChat export, so this function just autosubscribes all- users to every public stream. This returns a list of Subscription- dicts.- """- subscriptions: List[ZerverFieldsT] = []-- public_stream_ids = {stream["id"] for stream in zerver_stream if not stream["invite_only"]}-- public_stream_recipient_ids = {- recipient["id"]- for recipient in zerver_recipient- if recipient["type"] == Recipient.STREAM and recipient["type_id"] in public_stream_ids- }-- user_ids = [user["id"] for user in zerver_userprofile]-- for recipient_id in public_stream_recipient_ids:- for user_id in user_ids:- subscription = build_subscription(- recipient_id=recipient_id,- user_id=user_id,- subscription_id=NEXT_ID("subscription"),- )- subscriptions.append(subscription)-- return subscriptions--class GetUsers(Protocol):def __call__(self, stream_id: int = ..., huddle_id: int = ...) -> Set[int]:...@@ -618,37 +582,6 @@ def process_avatars(return avatar_list + avatar_original_list-def write_avatar_png(avatar_folder: str, realm_id: int, user_id: int, bits: bytes) -> ZerverFieldsT:- """- Use this function for conversions like HipChat where- the bits for the .png file come in something like- a users.json file, and where we don't have to- fetch avatar images externally.- """- avatar_hash = user_avatar_path_from_ids(- user_profile_id=user_id,- realm_id=realm_id,- )-- image_fn = avatar_hash + ".original"- image_path = os.path.join(avatar_folder, image_fn)-- with open(image_path, "wb") as image_file:- image_file.write(bits)-- # Return metadata that eventually goes in records.json.- metadata = dict(- path=image_path,- s3_path=image_path,- realm_id=realm_id,- user_profile_id=user_id,- # We only write the .original file; ask the importer to do the thumbnailing.- importer_should_thumbnail=True,- )-- return metadata--ListJobData = TypeVar("ListJobData")diff --git a/zerver/lib/bot_lib.py b/zerver/lib/bot_lib.pyindex e179b2de470..e708f43fe85 100644--- a/zerver/lib/bot_lib.py+++ b/zerver/lib/bot_lib.py@@ -1,10 +1,10 @@import importlibimport json-import osfrom typing import Any, Callable, Dict, Optionalfrom django.conf import settingsfrom django.utils.translation import gettext as _+from zulip_bots.lib import BotIdentity, RateLimitfrom zerver.lib.actions import (internal_send_huddle_message,@@ -22,10 +22,6 @@ from zerver.lib.integrations import EMBEDDED_BOTSfrom zerver.lib.topic import get_topic_from_message_infofrom zerver.models import UserProfile, get_active_user-our_dir = os.path.dirname(os.path.abspath(__file__))--from zulip_bots.lib import BotIdentity, RateLimit-def get_bot_handler(service_name: str) -> Any:diff --git a/zerver/lib/cache_helpers.py b/zerver/lib/cache_helpers.pyindex 37a8d85e759..04439b05520 100644--- a/zerver/lib/cache_helpers.py+++ b/zerver/lib/cache_helpers.py@@ -5,7 +5,6 @@ from typing import Any, Callable, Dict, List, Tuplefrom django.conf import settingsfrom django.contrib.sessions.models import Session-from django.db.models import Qfrom django.utils.timezone import now as timezone_now# This file needs to be different from cache.py because cache.py@@ -17,45 +16,20 @@ from zerver.lib.cache import (get_remote_cache_requests,get_remote_cache_time,get_stream_cache_key,- to_dict_cache_key_id,user_profile_by_api_key_cache_key,user_profile_cache_key,)-from zerver.lib.message import MessageDictfrom zerver.lib.sessions import session_enginefrom zerver.lib.users import get_all_api_keysfrom zerver.models import (Client,Huddle,- Message,Stream,UserProfile,get_client_cache_key,huddle_hash_cache_key,)-MESSAGE_CACHE_SIZE = 75000---def message_fetch_objects() -> List[Any]:- try:- max_id = Message.objects.only("id").order_by("-id")[0].id- except IndexError:- return []- return Message.objects.select_related().filter(- ~Q(sender__email="tabbott/[email protected]"), id__gt=max_id - MESSAGE_CACHE_SIZE- )---def message_cache_items(items_for_remote_cache: Dict[str, Tuple[bytes]], message: Message) -> None:- """- Note: this code is untested, and the caller has been- commented out for a while.- """- key = to_dict_cache_key_id(message.id)- value = MessageDict.to_dict_uncached([message])[message.id]- items_for_remote_cache[key] = (value,)-def user_cache_items(items_for_remote_cache: Dict[str, Tuple[UserProfile]], user_profile: UserProfile@@ -142,10 +116,6 @@ cache_fillers: Dict[10000,),"stream": (get_streams, stream_cache_items, 3600 * 24 * 7, 10000),- # Message cache fetching disabled until we can fix the fact that it- # does a bunch of inefficient memcached queries as part of filling- # the display_recipient cache- # 'message': (message_fetch_objects, message_cache_items, 3600 * 24, 1000),"huddle": (lambda: Huddle.objects.select_related().all(),huddle_cache_items,diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.pyindex ac6f2325b64..04f2dafda7f 100644--- a/zerver/lib/event_schema.py+++ b/zerver/lib/event_schema.py@@ -85,14 +85,6 @@ subscription_fields: Sequence[Tuple[str, object]] = []-equals_add_or_remove = UnionType(- [- # force vertical- Equals("add"),- Equals("remove"),- ]-)-value_type = UnionType([# force vertical formattingdiff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex c555f69a361..5b23d1934d7 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -77,13 +77,11 @@ FilterArgs = Dict[str, Any]IdSource = Tuple[TableName, Field]SourceFilter = Callable[[Record], bool]-# These next two types are callbacks, which mypy does not+# This next type is a callback, which mypy does not# support well, because PEP 484 says "using callbacks# with keyword arguments is not perceived as a common use case."# CustomFetch = Callable[[TableData, Config, Context], None]-# PostProcessData = Callable[[TableData, Config, Context], None]CustomFetch = Any # TODO: make more specific, see above-PostProcessData = Any # TODO: make more specific# The keys of our MessageOutput variables are normally# List[Record], but when we write partials, we can getdiff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex d2f9f051edf..27bd9757b3c 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -122,13 +122,6 @@ def verbose_compile(pattern: str) -> Pattern[str]:)-def normal_compile(pattern: str) -> Pattern[str]:- return re.compile(- fr"^(.*?){pattern}(.*)$",- re.DOTALL | re.UNICODE,- )--STREAM_LINK_REGEX = r"""(?<![^\s'"\(,:<]) # Start after whitespace or specified chars\#\*\* # and after hash sign followed by double asterisksdiff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex cd508f286ab..153dfe27612 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -53,8 +53,6 @@ from zerver.models import (query_for_ids,)-RealmAlertWord = Dict[int, List[str]]-class RawReactionRow(TypedDict):emoji_code: strdiff --git a/zerver/lib/rest.py b/zerver/lib/rest.pyindex 6ada29b574a..c26e69c7e32 100644--- a/zerver/lib/rest.py+++ b/zerver/lib/rest.py@@ -19,7 +19,6 @@ from zerver.lib.response import json_method_not_allowedfrom zerver.lib.types import ViewFuncTMETHODS = ("GET", "HEAD", "POST", "PUT", "DELETE", "PATCH")-FLAGS = "override_api_url_scheme"def default_never_cache_responses(view_func: ViewFuncT) -> ViewFuncT:diff --git a/zerver/lib/test_console_output.py b/zerver/lib/test_console_output.pyindex 03badc5f89d..49d7cd00bff 100644--- a/zerver/lib/test_console_output.py+++ b/zerver/lib/test_console_output.py@@ -11,7 +11,6 @@ class ExtraConsoleOutputInTestException(Exception):class ExtraConsoleOutputFinder:def __init__(self) -> None:- self.latest_test_name = ""valid_line_patterns = [# Example: Running zerver.tests.test_attachments.AttachmentsTests.test_delete_unauthenticated"^Running ",diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.pyindex a458d44d8c0..72a57c26bbe 100644--- a/zerver/lib/test_helpers.py+++ b/zerver/lib/test_helpers.py@@ -311,7 +311,6 @@ class HostRequestMock(HttpRequest):self.POST[key] = str(post_data[key])self.method = "POST"- self._log_data: Dict[str, Any] = {}if meta_data is None:self.META = {"PATH_INFO": "test"}else:diff --git a/zerver/lib/topic.py b/zerver/lib/topic.pyindex e800b3ce30a..91351547ad6 100644--- a/zerver/lib/topic.py+++ b/zerver/lib/topic.py@@ -214,7 +214,7 @@ def generate_topic_history_from_db_rows(rows: List[Tuple[str, int]]) -> List[Diccanonical_topic_names[canonical_name] = (max_message_id, topic_name)history = []- for canonical_topic, (max_message_id, topic_name) in canonical_topic_names.items():+ for max_message_id, topic_name in canonical_topic_names.values():history.append(dict(name=topic_name, max_id=max_message_id),)diff --git a/zerver/lib/utils.py b/zerver/lib/utils.pyindex 228ae9a0254..5244b87caa7 100644--- a/zerver/lib/utils.py+++ b/zerver/lib/utils.py@@ -4,8 +4,7 @@ import itertoolsimport reimport secretsfrom itertools import zip_longest-from time import sleep-from typing import Any, Callable, Iterator, List, Optional, Sequence, Set, Tuple, TypeVar+from typing import Any, Callable, Iterator, List, Optional, Set, Tuple, TypeVarfrom django.conf import settings@@ -58,33 +57,6 @@ class StatsDWrapper:statsd = StatsDWrapper()-# Runs the callback with slices of all_list of a given batch_size-def run_in_batches(- all_list: Sequence[T],- batch_size: int,- callback: Callable[[Sequence[T]], None],- sleep_time: int = 0,- logger: Optional[Callable[[str], None]] = None,-) -> None:- if len(all_list) == 0:- return-- limit = (len(all_list) // batch_size) + 1- for i in range(limit):- start = i * batch_size- end = (i + 1) * batch_size- if end >= len(all_list):- end = len(all_list)- batch = all_list[start:end]-- if logger:- logger(f"Executing {end-start} in batch {i+1} of {limit}")-- callback(batch)-- if i != limit - 1:- sleep(sleep_time)-def make_safe_digest(string: str, hash_func: Callable[[bytes], Any] = hashlib.sha1) -> str:"""diff --git a/zerver/models.py b/zerver/models.pyindex 2aa7d95a771..b797e4e1ab9 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -1550,9 +1550,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):# API rate limits, formatted as a comma-separated list of range:max pairsrate_limits: str = models.CharField(default="", max_length=100)- # Hours to wait before sending another email to a user- EMAIL_REMINDER_WAITPERIOD = 24-# Default streams for some deprecated/legacy classes of bot users.default_sending_stream: Optional["Stream"] = models.ForeignKey("zerver.Stream",diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.pyindex f844e4b2533..c570cbb5456 100644--- a/zerver/openapi/python_examples.py+++ b/zerver/openapi/python_examples.py@@ -16,11 +16,10 @@ import jsonimport osimport sysfrom functools import wraps-from typing import Any, Callable, Dict, Iterable, List, Optional, Set, TypeVar, cast+from typing import Any, Callable, Dict, List, Set, TypeVar, castfrom zulip import Client-from zerver.lib import mdifffrom zerver.models import get_realm, get_userfrom zerver.openapi.openapi import validate_against_openapi_schema@@ -1428,58 +1427,6 @@ def test_invalid_stream_error(client: Client) -> None:# SETUP METHODS FOLLOW-def test_against_fixture(- result: Dict[str, Any],- fixture: Dict[str, Any],- check_if_equal: Optional[Iterable[str]] = None,- check_if_exists: Optional[Iterable[str]] = None,-) -> None:- assertLength(result, fixture)-- if check_if_equal is None and check_if_exists is None:- for key, value in fixture.items():- assertEqual(key, result, fixture)-- if check_if_equal is not None:- for key in check_if_equal:- assertEqual(key, result, fixture)-- if check_if_exists is not None:- for key in check_if_exists:- assertIn(key, result)---def assertEqual(key: str, result: Dict[str, Any], fixture: Dict[str, Any]) -> None:- if result[key] != fixture[key]:- first = f"{key} = {result[key]}"- second = f"{key} = {fixture[key]}"- raise AssertionError(- "Actual and expected outputs do not match; showing diff:\n"- + mdiff.diff_strings(first, second)- )- else:- assert result[key] == fixture[key]---def assertLength(result: Dict[str, Any], fixture: Dict[str, Any]) -> None:- if len(result) != len(fixture):- result_string = json.dumps(result, indent=4, sort_keys=True)- fixture_string = json.dumps(fixture, indent=4, sort_keys=True)- raise AssertionError(- "The lengths of the actual and expected outputs do not match; showing diff:\n"- + mdiff.diff_strings(result_string, fixture_string)- )- else:- assert len(result) == len(fixture)---def assertIn(key: str, result: Dict[str, Any]) -> None:- if key not in result.keys():- raise AssertionError(- f"The actual output does not contain the the key `{key}`.",- )- else:- assert key in resultdef test_messages(client: Client, nonadmin_client: Client) -> None:diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.pyindex 14ad1874ca7..aa243d7cb27 100644--- a/zerver/tests/test_auth_backends.py+++ b/zerver/tests/test_auth_backends.py@@ -819,7 +819,6 @@ class SocialAuthBase(DesktopFlowTestingLib, ZulipTestCase):SIGNUP_URL: strAUTHORIZATION_URL: strAUTH_FINISH_URL: str- CONFIG_ERROR_URL: strACCESS_TOKEN_URL: strUSER_INFO_URL: strCLIENT_KEY_SETTING: str@@ -1780,7 +1779,6 @@ class SAMLAuthBackendTest(SocialAuthBase):SIGNUP_URL = "/accounts/register/social/saml/test_idp"AUTHORIZATION_URL = "https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO"AUTH_FINISH_URL = "/complete/saml/"- CONFIG_ERROR_URL = "/config-error/saml"# We have to define our own social_auth_test as the flow of SAML authentication# is different from the other social backends.@@ -2651,7 +2649,6 @@ class AppleAuthMixin:AUTHORIZATION_URL = "https://appleid.apple.com/auth/authorize"ACCESS_TOKEN_URL = "https://appleid.apple.com/auth/token"AUTH_FINISH_URL = "/complete/apple/"- CONFIG_ERROR_URL = "/config-error/apple"def generate_id_token(self, account_data_dict: Dict[str, str], audience: Optional[str] = None@@ -3033,7 +3030,6 @@ class GenericOpenIdConnectTest(SocialAuthBase):JWKS_URL = f"{BASE_OIDC_URL}/jwks"USER_INFO_URL = f"{BASE_OIDC_URL}/userinfo"AUTH_FINISH_URL = "/complete/oidc/"- CONFIG_ERROR_URL = "/config-error/oidc"def social_auth_test(self,@@ -3215,7 +3211,6 @@ class GitHubAuthBackendTest(SocialAuthBase):ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token"USER_INFO_URL = "https://api.github.com/user"AUTH_FINISH_URL = "/complete/github/"- CONFIG_ERROR_URL = "/config-error/github"email_data: List[Dict[str, Any]] = []def social_auth_test_finish(@@ -3737,7 +3732,6 @@ class GitLabAuthBackendTest(SocialAuthBase):ACCESS_TOKEN_URL = "https://gitlab.com/oauth/token"USER_INFO_URL = "https://gitlab.com/api/v4/user"AUTH_FINISH_URL = "/complete/gitlab/"- CONFIG_ERROR_URL = "/config-error/gitlab"def test_gitlab_auth_enabled(self) -> None:with self.settings(AUTHENTICATION_BACKENDS=("zproject.backends.GitLabAuthBackend",)):@@ -3759,7 +3753,6 @@ class GoogleAuthBackendTest(SocialAuthBase):ACCESS_TOKEN_URL = "https://accounts.google.com/o/oauth2/token"USER_INFO_URL = "https://www.googleapis.com/oauth2/v3/userinfo"AUTH_FINISH_URL = "/complete/google/"- CONFIG_ERROR_URL = "/config-error/google"def get_account_data_dict(self, email: str, name: str) -> Dict[str, Any]:return dict(email=email, name=name, email_verified=True)diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.pyindex 7432bb81bc4..a24118b85d6 100644--- a/zerver/tests/test_push_notifications.py+++ b/zerver/tests/test_push_notifications.py@@ -2,7 +2,6 @@ import asyncioimport base64import datetimeimport itertools-import osimport reimport uuidfrom contextlib import contextmanager@@ -87,8 +86,6 @@ if settings.ZILENCER_ENABLED:RemoteZulipServer,)-ZERVER_DIR = os.path.dirname(os.path.dirname(__file__))-@skipUnless(settings.ZILENCER_ENABLED, "requires zilencer")class BouncerTestCase(ZulipTestCase):diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex dade5d769e7..4b05a81b129 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -182,10 +182,6 @@ class ClientDescriptor:ret.last_connection_time = d["last_connection_time"]return ret- def prepare_for_pickling(self) -> None:- self.current_handler_id = None- self._timeout_handle = None-def add_event(self, event: Mapping[str, Any]) -> None:if self.current_handler_id is not None:handler = get_handler_by_id(self.current_handler_id)@@ -709,11 +705,6 @@ def fetch_events(query: Mapping[str, Any]) -> Dict[str, Any]:return dict(type="async")-# Send email notifications to idle users-# after they are idle for 1 hour-NOTIFY_AFTER_IDLE_HOURS = 1--def build_offline_notification(user_profile_id: int, message_id: int) -> Dict[str, Any]:return {"user_profile_id": user_profile_id,diff --git a/zerver/webhooks/flock/view.py b/zerver/webhooks/flock/view.pyindex 4a68544c6a5..dc7a7105005 100644--- a/zerver/webhooks/flock/view.py+++ b/zerver/webhooks/flock/view.py@@ -9,8 +9,6 @@ from zerver.lib.response import json_successfrom zerver.lib.webhooks.common import check_send_webhook_messagefrom zerver.models import UserProfile-CHECK_IS_REPLY = "in reply to"-@webhook_view("Flock")@has_request_variablesdiff --git a/zerver/webhooks/sonarqube/tests.py b/zerver/webhooks/sonarqube/tests.pyindex 6a3fe5e4d7a..195b6b78a79 100644--- a/zerver/webhooks/sonarqube/tests.py+++ b/zerver/webhooks/sonarqube/tests.py@@ -4,7 +4,6 @@ from zerver.lib.test_classes import WebhookTestCaseclass SonarqubeHookTests(WebhookTestCase):STREAM_NAME = "SonarQube"URL_TEMPLATE = "/api/v1/external/sonarqube?api_key={api_key}&stream={stream}"- FIXTURE_DIR_NAME = "sonarqube"WEBHOOK_DIR_NAME = "sonarqube"def test_analysis_success(self) -> None:diff --git a/zerver/webhooks/transifex/tests.py b/zerver/webhooks/transifex/tests.pyindex aa99b8ad0fc..c6ede1b024c 100644--- a/zerver/webhooks/transifex/tests.py+++ b/zerver/webhooks/transifex/tests.py@@ -13,10 +13,8 @@ class TransifexHookTests(WebhookTestCase):PROJECT = "project-title"LANGUAGE = "en"RESOURCE = "file"- REVIEWED = Truedef test_transifex_reviewed_message(self) -> None:- self.REVIEWED = Trueexpected_topic = f"{self.PROJECT} in {self.LANGUAGE}"expected_message = f"Resource {self.RESOURCE} fully reviewed."self.url = self.build_webhook_url(@@ -28,7 +26,6 @@ class TransifexHookTests(WebhookTestCase):self.check_webhook("", expected_topic, expected_message)def test_transifex_translated_message(self) -> None:- self.REVIEWED = Falseexpected_topic = f"{self.PROJECT} in {self.LANGUAGE}"expected_message = f"Resource {self.RESOURCE} fully translated."self.url = self.build_webhook_url(diff --git a/zilencer/forms.py b/zilencer/forms.pydeleted file mode 100644index b6f90c3832c..00000000000--- a/zilencer/forms.py+++ /dev/null@@ -1,7 +0,0 @@-from django import forms---class EnterpriseToSForm(forms.Form):- full_name = forms.CharField(max_length=100)- company = forms.CharField(max_length=100)- terms = forms.BooleanField(required=True)