Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
validator: Remove unused to_positive_or_allowed_int function.
Anders Kaseorg4fe030e6ea5d
diff --git a/zerver/lib/validator.py b/zerver/lib/validator.pyindex 175dade8e8a..3a7338eb518 100644--- a/zerver/lib/validator.py+++ b/zerver/lib/validator.py@@ -538,18 +538,6 @@ def to_non_negative_int(s: str, max_int_size: int = 2 ** 32 - 1) -> int:return x-def to_positive_or_allowed_int(allowed_integer: Optional[int] = None) -> Callable[[str], int]:- def converter(s: str) -> int:- x = int(s)- if allowed_integer is not None and x == allowed_integer:- return x- if x == 0:- raise ValueError("argument is 0")- return to_non_negative_int(s)-- return converter--def to_float(s: str) -> float:return float(s)diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex c3c9417d91f..8330cdf064d 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -81,7 +81,6 @@ from zerver.lib.validator import (check_url,equals,to_non_negative_int,- to_positive_or_allowed_int,)from zerver.middleware import parse_clientfrom zerver.models import Realm, UserProfile, get_realm, get_user@@ -773,22 +772,6 @@ class ValidatorTestCase(ZulipTestCase):with self.assertRaisesRegex(ValueError, re.escape(f"{2**32} is too large (max {2**32-1})")):to_non_negative_int(str(2 ** 32))- def test_to_positive_or_allowed_int(self) -> None:- self.assertEqual(to_positive_or_allowed_int()("5"), 5)- self.assertEqual(to_positive_or_allowed_int(-1)("5"), 5)-- self.assertEqual(to_positive_or_allowed_int(-1)("-1"), -1)- with self.assertRaisesRegex(ValueError, "argument is negative"):- to_positive_or_allowed_int(-1)("-5")- with self.assertRaisesRegex(ValueError, "argument is negative"):- to_positive_or_allowed_int()("-5")-- with self.assertRaises(ValueError):- to_positive_or_allowed_int(-1)("0")- with self.assertRaises(ValueError):- to_positive_or_allowed_int()("0")- self.assertEqual(to_positive_or_allowed_int(0)("0"), 0)-def test_check_float(self) -> None:x: Any = 5.5check_float("x", x)