From 656c0ead8750a5630080a6bd0c63b1bae52a478f Mon Sep 17 00:00:00 2001 From: kibablu <50038533+kibablu@users.noreply.github.com> Date: Tue, 25 May 2021 19:22:18 +0300 Subject: [PATCH] Improve static type checking (#225) * Improve static type checking Add type annotation to is_too_long Function on apnstruncate.py file as part of #201 issue Signed-off-by: Omar Mohamed --- changelog.d/225.misc | 1 + sygnal/apnstruncate.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/225.misc diff --git a/changelog.d/225.misc b/changelog.d/225.misc new file mode 100644 index 00000000..e62c523c --- /dev/null +++ b/changelog.d/225.misc @@ -0,0 +1 @@ +Improve static type checking. Contributed by Omar Mohamed. \ No newline at end of file diff --git a/sygnal/apnstruncate.py b/sygnal/apnstruncate.py index 03f2362e..5448f6f0 100644 --- a/sygnal/apnstruncate.py +++ b/sygnal/apnstruncate.py @@ -26,7 +26,7 @@ class BodyTooLongException(Exception): pass -def is_too_long(payload, max_length=2048): +def is_too_long(payload: dict, max_length: int = 2048) -> bool: """ Returns True if the given payload dictionary is too long for a push. Note that the maximum is now 2kB "In iOS 8 and later" although in