Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
validator: Remove unused check_tuple function.
Anders Kaseorg404ef284bb70
diff --git a/zerver/lib/validator.py b/zerver/lib/validator.pyindex ba2ac99c7e8..175dade8e8a 100644--- a/zerver/lib/validator.py+++ b/zerver/lib/validator.py@@ -217,29 +217,6 @@ def check_list(return f-def check_tuple(sub_validators: List[Validator[ResultT]]) -> Validator[Tuple[Any, ...]]:- def f(var_name: str, val: object) -> Tuple[Any, ...]:- if not isinstance(val, tuple):- raise ValidationError(_("{var_name} is not a tuple").format(var_name=var_name))-- desired_len = len(sub_validators)- if desired_len != len(val):- raise ValidationError(- _("{var_name} should have exactly {desired_len} items").format(- var_name=var_name,- desired_len=desired_len,- )- )-- for i, sub_validator in enumerate(sub_validators):- vname = f"{var_name}[{i}]"- sub_validator(vname, val[i])-- return val-- return f--# https://zulip.readthedocs.io/en/latest/testing/mypy.html#using-overload-to-accurately-describe-variations@overloaddef check_dict(diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex ad31f5c1744..c3c9417d91f 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -77,7 +77,6 @@ from zerver.lib.validator import (check_string_in,check_string_or_int,check_string_or_int_list,- check_tuple,check_union,check_url,equals,@@ -817,21 +816,6 @@ class ValidatorTestCase(ZulipTestCase):with self.assertRaisesRegex(ValidationError, r"color is not a string"):check_color("color", z)- def test_check_tuple(self) -> None:- x: Any = 999- with self.assertRaisesRegex(ValidationError, r"x is not a tuple"):- check_tuple([check_string])("x", x)-- x = (5, 2)- with self.assertRaisesRegex(ValidationError, r"x\[0\] is not a string"):- check_tuple([check_string, check_string])("x", x)-- x = (1, 2, 3)- with self.assertRaisesRegex(ValidationError, r"x should have exactly 2 items"):- check_tuple([check_int, check_int])("x", x)-- check_tuple([check_string, check_int])("x", ("string", 42))-def test_check_list(self) -> None:x: Any = 999with self.assertRaisesRegex(ValidationError, r"x is not a list"):